Jump to content

health pack


Gamer4Life
 Share

Recommended Posts

I was trying to get a health pack pick up script working from a leadwerks tutorial video and for some reason I'm getting a script nil value on line 11 at ,( if player.script.health < player.script.maxHealth then. ) Anyone know why?

Script.health = 25.0 --float "Health"
Script.useOnce = true --bool "Use once"
function Script:Start()
if  self.health < 0 then

 error ("Health can't be a negative value.")
end
end
function Script:Use(player)
if player.script.health < player.script.maxHealth then
 player.script:ReceiveHealth(self.health)
 if self.useOnce then
  self.entity:Release()
 end
end

end

Link to comment
Share on other sites

Thanks Rick. That was the issue. It took me a while to figure out the line underneath it after I changed the line to what you recommended but essentially since it would not let me use the script I had to identify each by name. If anyone needs a health pack code that seemed to work for me.

Script.health = 25.0 --float "Health"
Script.useOnce = true --bool "Use once"
function Script:Start()
if  self.health < 0 then

 error ("Health can't be a negative value.")
end
end
function Script:Use(player)
if player.health < player.maxHealth then  
player.health = self.health + player.health
 if self.useOnce then
  self.entity:Release()
 end
end

end

Link to comment
Share on other sites

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...