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

Why does my script print the health as 100 while it is 1 and why does it not heal the player?

Asked by 3 years ago
Edited 3 years ago
local healingpad = script.Parent ---Healing Pad
local Green = Color3.fromRGB(96, 255, 99) ---Color Green
local Red = Color3.fromRGB(255,53,53) ---Color Red
local coolDown = 5 ---Cooldown Time
local debounce = false

function heal (hit)
    if debounce then return end
    if hit.Parent:FindFirstChild("Humanoid") then

        print("health")
        print(hit.Parent.Humanoid.Health)
        hit.Parent.Humanoid.Health += 25
        debounce = true
        wait(coolDown)
        debounce = false

    end
end

healingpad.Touched:Connect(heal)

I made this healing script but it doesn't work. Idk why though.

0
Maybe you're substracting the health on the client so the server doesn't see it being lower? Amiaa16 3227 — 3y
0
How do I subtract it on the server? raahatu 6 — 3y
0
By changing it from a LocalScript to a Script. pwx 1581 — 3y
0
it is a server script tho raahatu 6 — 3y
View all comments (4 more)
0
it is inside of the healing pad part raahatu 6 — 3y
0
For some reason setting it to equal works but not adding to it. raahatu 6 — 3y
0
Nothing wrong with your script. But you're most likely setting the health to 1 on the client while testing it. Switch to server and set the health before you test the script. radiant_Light203 1166 — 3y
0
Thanks can you put that as the answer so I can mark it as answered. raahatu 6 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Nothing wrong with your script. But you're most likely setting the health to 1 on the client while testing it. Switch to server and set the health before you test the script.

Ad

Answer this question