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.
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)
local on = false script.Parent.MouseButton1Click:Connect(function() if on == false then plr.Character.Humanoid.WalkSpeed = 0 local force = Instance.new("ForceField") force.Parent = script.Parent.Parent.Parent.Parent.Character on = true else plr.Character.Humanoid.WalkSpeed = 32 script.Parent.Parent.Parent.Parent.Character.ForceField:Destroy() on = false end end)
Hopefully this works! Put it in a local script in your button.