• Glitch or programming error with SetHealth entity?
    34 replies, posted
I was stating "my math.Clamp" as the one I gave, not that I own it. If I stated I owned it, then I would be a moron now, would I not? And we're pointing out the fact that you have this inability to read and you keep putting it within the code block, which causes it to [b]not work[/b]. [t]http://i.imgur.com/r5KwmNf.png[/t] Remember that? That worked because you removed the if statement, so here's what you need to do. Take the self:Remove() outside of the fucking code block. Good?
[editline]15th May 2014[/editline] [QUOTE=brandonj4;44819021]You still have the exact same Use function as before. Instead of just skimming through a post you should actually read it because many people have given you the answer.[/QUOTE] Why are you assuming that I'm skimming through stuff, you don't think I've tried everything? Why do you think I haven't marked it as solved yet? [editline]15th May 2014[/editline] [QUOTE=Nookyava;44819187]I was stating "my math.Clamp" as the one I gave, not that I own it. If I stated I owned it, then I would be a moron now, would I not? And we're pointing out the fact that you have this inability to read and you keep putting it within the code block, which causes it to [b]not work[/b]. [t]http://i.imgur.com/r5KwmNf.png[/t] Remember that? That worked because you removed the if statement, so here's what you need to do. Take the self:Remove() outside of the fucking code block. Good?[/QUOTE] It's in the block because I don't want it being removed unless someone is receiving health. Look, obviously you guys are getting different results than me. As the question suggests I only wanted to know if it was my own error or something else. You wouldn't understand if I told you the Remove() wasn't doing it's job properly, for me at least.
If the player using the entity has less than 100 health, you want to increase their health and remove the entity, right? If the players health is already greater than or equal to 100, no health is given and the entity should stay? If that's the case then the most recent code you've posted should work as far as I can see. I rewrote it more verbose, but it should be identical. I added a print statement and I'd be very surprised if this printed REMOVING more than once. [lua]function ENT:Use( ply ) --Get the players health local CurHealth = ply:Health() --Check if their health is less than 100 if CurHealth<100 then --Calculate new health local NewHealth = math.min(ply:Health()+75, 100) --Increase their health ply:SetHealth( NewHealth ) --Remove the entity print("REMOVING") self:Remove() end end[/lua]
Never Ctrl + S a script you made for someone on Facepunch. I found this hidden inside another script, it's a habit of mine to Ctrl + S often. [CODE] hook.Add( "PlayerUse", "GiveHealthFromAnything", function(ply, entity) ply:SetHealth(100) return true end) [/CODE]
[QUOTE=Winter;44819592]Never Ctrl + S a script you made for someone on Facepunch. I found this hidden inside another script, it's a habit of mine to Ctrl + S often. [CODE] hook.Add( "PlayerUse", "GiveHealthFromAnything", function(ply, entity) ply:SetHealth(100) return true end) [/CODE][/QUOTE] It is your own fault if you don't watch what copy paste.
Sorry, you need to Log In to post a reply to this thread.