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
Add the if statement inside the function
Never define a function within anything. Flip the function and the if statement.