So I'm trying to give a turret a muzzle flash and I'm doing it by creating a light that will appear and disappear.
Here is my script:
Script.player = "" --entity "Player"
Script.rotSpeed = 0.1 --float "Rotation Speed"
Script.fireRate = 1.0 --float "Fire rate"
Script.fireRateTimer = 0
Script.muzzleFlash = "" --entity "Muzzle flash light"
Script.muzzleTime = 0.1 --float "Muzzle time"
Script.muzzleTimer = 0
function Script:Start()
self.muzzleFlash:Hide()
end
function Script:UpdateWorld()
self.entity:Point(self.player, 2, Time:GetSpeed() * self.rotSpeed)
self.fireRateTimer = self.fireRateTimer + (Time:GetSpeed()/100)
self.muzzleTimer = self.muzzleTimer + (Time:GetSpeed()/100)
if(self.fireRateTimer > self.fireRate) then
self.muzzleFlash:Show()
self.muzzleTimer = 0
self.FireRateTimer = 0
end
if (self.muzzleTimer > self.muzzleTime) then
self.muzzleFlash:Hide()
end
end
When I run the game I get the error "10 : attempt to call method 'Hide' (a nil value)"
Any ideas what could be wrong?