Despite adding a forcefield, you are still able to lose health, apparently.
local force
local on = false
script.Parent.MouseButton1Down:connect(function()
local player = script.Parent.Parent.Parent.Parent
on = not on
if on then
player.Character.Humanoid.WalkSpeed = 0
force = Instance.new("ForceField",player.Character)
else
force:Destroy()
player.Character.Humanoid.WalkSpeed = 32
end
end)

2 comments
dumb it down for me i am scripting boomer
Set a variable with the player's health in it, and as long as they are AFK their health should always be set to that variable.