Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Speed Script, How do I make the speed reset?

I've made this speed script however I was wondering how can I make this script if it were to executed again the speed would reset back to normal or remove it however when I click it again it should come back

game:GetService("UserInputService").InputBegan:connect(function(inputObject,gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.W then
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 200
    end 
end)

1 answer

✓ Accepted answer

You'd simply need an extra if statement to check if it was enabled last time, you can also do this in one line using the and and or operators when asigning a variable.

#Some explaination Pretty much what this does is, if the first value is true, use the and, else use the or.

Here are some examples.

local var = true and 1 or 2 would be 1,

local var = false and 1 or 2 would be 2,

local var = true and 1 and 2 or 3 would be 2

local var = false and 1 or 2 and 3 would be 3, as a number is not nil or false, thus thrutly

#Code

local Player = game.Players.LocalPlayer
game:GetService("UserInputService").InputBegan:connect(function(io,GPE)
    if not GPE and io.KeyCode == Enum.KeyCode.W then
        Player.Character.Humanoid.WalkSpeed = 
		Player.Character.Humanoid.WalkSpeed == 200 and 16 or 200
    end 
end)

3 comments

0

This is A Bad method

0

ur a bad method

0

This is a very good method.

This discussion is preserved as it was. New answers, comments, and votes are closed.