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

Does using the phrase Variable = Variable + 1 make it increase by 1?

This should cause the WalkSpeed of the players to increase by 1 everytime "R" is pressed.

It doesn't work

Player = game.Players.LocalPlayer Character = Player.Character Humanoid = Character.Humanoid WalkSpeed = Humanoid.WalkSpeed

game:GetService("UserInputService").InputBegan:connect(function(LetsSee) if LetsSee.KeyCode == Enum.KeyCode.R then print("R was pressed") WalkSpeed = WalkSpeed + 1 end end)

1 answer

This is because you are incrementing the value of your WalkSpeed variable, and not the WalkSpeed property of the player character's Humanoid object. WalkSpeed and Character.Humanoid.WalkSpeed are two different variables.

4 comments

0

I made WalkSpeed = Humanoid.WalkSpeed, Humanoid = Character.Humanoid, Character = Player.Character, Player = game.Players.LocalPlayer

0

So WalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed

0

Yes, but "Walkspeed" alone is a separate variable from "Humanoid.Walkspeed".

0

To be more specific, variable "WalkSpeed" is set to the player's WalkSpeed value, and not the value itself.

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