Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Healing doesnt really register?

Asked by 7 years ago

So I made a tool that heals your health to 100, and guns that are ray guns that shoot and decrease your health. My problem was, sometimes while you were getting shot at, and you healed, it wouldn't actually heal you, the heal cooldown that I implemented would go off. So I thought this was an issue with the humanoid's health, so I tried making a new number value that would replace the health and have the script say that if the number reaches 0 i killed the humanoid and i can have max number for that be 100.

I eventually was able to replicate this effect in studio and ingame by having a block that if you touch decreasing the value by 1 and is kinda flickering in that position by moving it up and down and I got the same problem, but I was able to get a better understanding of what was going on by having the value printed https://gyazo.com/0e2c02afca62df6164d47cbe7604b78f (see how the number goes to 100, which is what I want it to do, remember that it doesn't do this in studio but only does this problem in game) that is a gif showing the problem I have, maybe it has something to do with my number being local, I'm not sure. so maybe somebody knows a quick fix to this --this is the script I put in the number value in the character model

MaxFabHealth = script.Parent.Parent:WaitForChild("MaxFabHealth")

function UpdateValue()
    print("".. script.Parent.Value .. "")
    if script.Parent.Value >= script.Parent.Parent.MaxFabHealth.Value then
        script.Parent.Value = script.Parent.Parent.MaxFabHealth.Value
    end
    if script.Parent.Value <= 0 then
        script.Parent.Parent.Humanoid.Health = 0
    end
end

script.Parent.Changed:connect(UpdateValue)

-- this is my first time using this site and I'm not a very experienced scripter so yeah my only goal here is to be able to have a tool that heals you by just clicking it and have it so while your getting shot at you can heal in the middle of getting shot without it glitching and not actually healing you. Any ideas?

Answer this question