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

im trying to make it so when button clicked it heals but i need to fix my code any one help?

Asked by 2 years ago
script.Parent.Fire.OnServerEvent:Connect(function(player)
    local Figure = script.Parent
    local Head = Figure:WaitForChild("Head")
    local Humanoid = Figure:WaitForChild("Humanoid")
    -- regeneration
    while true do
        wait(0.5)
        while Humanoid.Health < Humanoid.MaxHealth do
            wait(0.125)
            Humanoid.Health = Humanoid.Health + 1
        end

        wait(20)
        end
        wait(35)
end)

this works on its own but I want it to be on button click not automatic

    local Figure = script.Parent
    local Head = Figure:WaitForChild("Head")
    local Humanoid = Figure:WaitForChild("Humanoid")
    -- regeneration
    while true do
        wait(0.5)
        while Humanoid.Health < Humanoid.MaxHealth do
            wait(0.125)
            Humanoid.Health = Humanoid.Health + 1
        end

Answer this question