Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im trying to make a AFK Gui, but if the health is below 100 it still works?

So I'm trying to make a AFK GUI that only works if the health is at 100. If the health is at 100 it changes the players health to 9999, and removes the players tools. It then has a 60 second countdown and after the 60 seconds it give back the tools and changes the health back to 100.

if game.Players.LocalPlayer.Character.Humanoid.Health == 100 then 
    function action()
    game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999
    game.Players.LocalPlayer.Character.Humanoid.Health = 9999
    game.Players.LocalPlayer.Backpack.Clean:Remove()
    wait(0.1)
    local time = 60
    for i = 1, 60 do
    wait(1)
    time = time - 1
    script.Parent.Text = tostring(time) 
end
    game.Players.LocalPlayer.Character.Humanoid.Health = 100
    game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 9999
    game.Lighting.Tools.Clean:Clone().Parent = game.Players.LocalPlayer.Backpack


end
end






script.Parent.MouseButton1Click:connect(action)

2 comments

0

Add the if statement inside the function

0

Never define a function within anything. Flip the function and the if statement.

1 answer

Your question was already previously posted with an answer on it.

Literally, a duplicate of this script.

This discussion is preserved as it was. New answers, comments, and votes are closed.