Walkspeed changing script doesn't work

A friend of mine who isn’t a member yet, got a problem with a “Walkspeed Simulator” script. I also don’t know how to fix it and make it work. Can anyone help? What’s wrong?

-- Starting speed
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char.Humanoid
 
h.WalkSpeed = 10
end

-- Speeding up
while true do
  local player = game.Players.LocalPlayer
  local char = player.CharacterAdded:wait()
  local h = char.Humanoid
  wait(1)
  currentWalkspeed = h.WalkSpeed
  h.WalkSpeed = currentWalkspeed + 1
end
1 Like

This should be done on a Server Script. Using a PlayerAdded event, if this is already a ServerScript. LocalPlayer won’t work.

There is also a Random end at line 7

4 Likes

Ah okay, thanks for helping. I marked this as a solution.

1 Like

This isnt related but use compound assignment operators instead. They save like a second of writing another bit of code.

h.WalkSpeed += 1

You can always utilize it differently :slight_smile:

Lua does not support compound operators.

They do, read Release Notes 435.

http://developer.roblox.com/resources/release-note/Release-Notes-for-435

*Luau does support compound operators

Oh, what a pleasant surprise! :smiley: