I need to know if the following script would work correctly, if it will or I did something wrong, please leave feedback in the form of an answer, please.
Click > Walkspeed 100 Click Again > Walkspeed 15
local Player = game.Players.LocalPlayer local Humanoid = Player.Character.Humanoid function onClick() Humanoid.Walkspeed = 100 if Humanoid.Walkspeed == 100 then Humanoid.Walkspeed = 15 else Humanoid.Walkspeed 100 end script.Parent.MouseButton1Click:connect(onClick)
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character.Humanoid
function onClick()
Humanoid.Walkspeed = 100
if Humanoid.Walkspeed == 100 then Humanoid.Walkspeed = 15
else
Humanoid.Walkspeed 100
end
script.Parent.MouseButton1Click:connect(onClick)
Indenting affects the order in which code runs. So I'd suggest indenting the if and else statements.
local Player = game.Players.LocalPlayer local Hum = Player.Character:WaitForChild("Humanoid") script.Parent.MouseButton1Click:connect(function() if Hum.Walkspeed >= 100 then Hum.Walkspeed = 15 else Hum.Walkspeed = 100 end end)
Put this script in a textbutton inside a screen gui or where ever. Boom.
local player = game.Players.LocalPlayer function whenClicked() if player.Character.Humanoid.WalkSpeed == 16 then player.Character.Humanoid.WalkSpeed = 100 else if player.Character.Humanoid.WalkSpeed == 100 then player.Character.Humanoid.WalkSpeed = 16 end end end script.Parent.MouseButton1Click:connect(whenClicked)
This has been tested and works.