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

How to make a healing tool heal on touch?

Asked by 5 years ago
Edited by DeceptiveCaster 5 years ago

So, I have been trying to add a medic class into my roblox game. I decided that it would need a tool that would be able to heal teammates. I made the tool, (the entire tool is all in the part "Handle"). I put this script into my tool hoping it would make the tool heal any humanoid that touched the part. Here is the script:

local debounce = false
game.Players.LocalPlayer.Backpack.Healing.Handle.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if not debounce then
            debounce = true
                while hit.Parent.Humanoid.Health <100 do
                    hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Heath + 25
                    wait(5)
                end
                wait(5)
                debounce=false
        end
    end
end)

Personally, I am a new scripter and I think the proble may be about how I defined the tool. It all seemed right though.

The tool is called: Healing. The handle is called: Handle

Please tell me how to fix this code, Thanks!

0
Here is what I tried to do to fix it... Chubbyninja179 0 — 5y
0
local debounce = false script.Parent.Handle.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if not debounce then debounce = true while hit.Parent.Humanoid.Health <100 do hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Heath + 25 wait(5) end wait(5) debounce=false end end end) Chubbyninja179 0 — 5y
0
Are you intending for it to steadily heal the target until they're fully healed or do you want it to heal them every time they touch the part? XxTrueDemonxX 362 — 5y
0
I want them to heal everytime they touch the part. Chubbyninja179 0 — 5y

Answer this question