This is the code. The forcefield and walkspeed edit works when you first press it, but when you turn it off, it breaks, plus it keeps your walkspeed at 0 to top it all off.
This is the script:
local On = false
script.Parent.MouseButton1Down:connect(function()
local player = script.Parent.Parent.Parent.Parent
if On == false then
On = true
player.Character.Humanoid.WalkSpeed = 0
force = Instance.new("ForceField",player.Character)
elseif On == true then
force:remove()
player.Character.Humanoid.Walkspeed = 32
end
end)
How do I fix my afk button? I want it to freeze the player's walkspeed and add a forcefield to the player, yet I want that to disable properly when I turn it off. I also want to fix the issue where it breaks after 1 use.

5 comments
This script does not seem to work at all.
Made a typo. Change the uppercase On to on.
While you did fix my issue with the not being able to reuse button, the player still doesn't return from 0 walkspeed. The character stays at 0 speed despite the clear command to set it to 32.
Another typo Walkspeed -> WalkSpeed
Great stuff!