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

my selfmade heal pad script dont work?

Asked by 5 years ago

hey, i made a healpad script but it dont work

script.Parent.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.Health = humanoid.Health + 25 wait(1)

        end

end)
2
your lua brackets didnt work either DinozCreates 1070 — 5y
0
any errors? Try doing a print test. Is it a server script.... ForeverBrown 356 — 5y
0
The code is right, it must just how you implemented it. ForeverBrown 356 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

I believe you are trying to do a cooldown so it wont heal him fast. Well your script is almost correct. Let me fix it:

debounce = false
time = 1 --how long you want to wait (cooldown) before you can heal again

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if debounce == false then debounce = true --We set the debounce to true for the cooldown
        if humanoid then
            humanoid.Health = humanoid.Health + 25 --You cant just type hum.Health = +25.. it wont work.
            wait(time) --we wait
            debounce = false --debounce = false
        end
    end
end)

Good luck, keep scripting.

1
Good answer, though findFirstChild() is depreciated. Should be FindFirstChild() ForeverBrown 356 — 5y
0
I didnt notice I typed findFirstChild, sorry. I mean FindFirstChild. HeyItzDanniee 252 — 5y
1
@HeyItzDanniee did you know that you can also heal the Humanoid by doing TakeDamage(-25)? DeceptiveCaster 3761 — 5y
0
@MCAndRobloxUnited Seriously? Nice. Didn't know that, that's new. Thanks. HeyItzDanniee 252 — 5y
View all comments (4 more)
0
Hey, i tried it. But dont work. I tested where the problem is and i put a print("test") after the if humanoid. And it did not show up. So may this be the problem ? Revelo0904 0 — 5y
0
Im now trying to reinstall studio because i thing something is wrong with it. Even Scripts from the internet dont work. Revelo0904 0 — 5y
0
It should work as long as the script is a ServerScript inside the part you touch. Also... Uninstall ROBLOX and ROBPOX STUDIO, reboot your PC and then download ROBLOX Player and ROBLOX Studio again. HeyItzDanniee 252 — 5y
0
Trust me, had some issues with my studio too. Thanks to roblox I fixed it. Thats how I fixed it /\ HeyItzDanniee 252 — 5y
Ad

Answer this question