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

I'm trying to make a keybind regeneration script and i don't know what i did wrong?

Asked by 4 years ago

I looked in output and it didn't say any of my prints or give me any errors?

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() print(0)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

function onKeyPressed(inputObject,gameProcesssEvent) print(1)
    if inputObject.KeyCode == Enum.KeyCode.P then print(2)
        if humanoid.Health > 0 then print(3)
            while true do 

local REGEN_RATE = 5/100 -- Regenerate this fraction of MaxHealth per second. 
print("Worked")
local REGEN_STEP = 1 -- Wait this long between each regeneration step.


while true do
    while humanoid.Health < humanoid.MaxHealth do
        local dt = wait(REGEN_STEP)
    l   ocal dh = dt*REGEN_RATE*humanoid.MaxHealth
        humanoid.Health = math.min(humanoid.Health + dh, humanoid.MaxHealth)
    end
    humanoid.HealthChanged:Wait()
end
            end

        end 
    end
end

Answer this question