Jump to content

Attempt to call method 'Hide' (a nil value)


BenHoff
 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • 8 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...