BenHoff Posted November 3, 2014 Share Posted November 3, 2014 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? Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted November 3, 2014 Share Posted November 3, 2014 Did you assign an object to muzzleFlash? Quote Link to comment Share on other sites More sharing options...
BenHoff Posted November 3, 2014 Author Share Posted November 3, 2014 Did you assign an object to muzzleFlash? Yes, I did. I assigned a point light to it. Actually I figured it out, I applied the script to the light itself instead of the turret. Problem solved. 1 Quote Link to comment Share on other sites More sharing options...
The Mover Cell Posted June 7, 2023 Share Posted June 7, 2023 On 11/4/2014 at 6:20 AM, BenHoff said: Yes, I did. I assigned a point light to it. Actually I figured it out, I applied the script to the light itself instead of the turret. Problem solved. i now have the same errorcode but with self:Hide(), can you help me? Quote hi there Link to comment Share on other sites More sharing options...
The Mover Cell Posted June 7, 2023 Share Posted June 7, 2023 oh, i was supoosed to do self.entity sorry 2 Quote hi there Link to comment Share on other sites More sharing options...
Recommended Posts
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.