Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Number value won't change the walkspeed value?

Asked by
Kryddan 261 Moderation Voter
9 years ago

So i have a NumberValue in starterpack which is called "MovementSpeed" and the value of "MovementSpeed" is 20 and i am trying to do that my walkspeed is the same as the value of "MovementSpeed"'s value. But when i test it out i check my humanoid and i got 20 walkspeed, but if i would change the value of "MovementSpeed" in my backpack while i am in test mode my walkspeed would stay the same.

local player = script.Parent.Parent
local backpack = player:WaitForChild("Backpack")

repeat wait() until player.Character.Humanoid
local movespeed = backpack:WaitForChild("MovementSpeed").Value

player.Character.Humanoid.WalkSpeed = movespeed

backpack.MovementSpeed.Changed:connect(function()
    player.Character.Humanoid.WalkSpeed = movespeed
end)

btw i got no errors in the output either.

0
Suggestion: You should change everything to where the walkspeed = movespeed.Value. and remove the value part to the reference of movespeed BSIncorporated 640 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago
local player = script.Parent.Parent
local backpack = player:WaitForChild("Backpack")

repeat wait() until player.Character.Humanoid
local movespeed = backpack:WaitForChild("MovementSpeed")

player.Character.Humanoid.WalkSpeed = movespeed.Value

backpack.MovementSpeed.Changed:connect(function()
    player.Character.Humanoid.WalkSpeed = movespeed.Value --you need the .Value so it can update everytime this event occurs, before, you had the value set to 20 the whole time.
end)

2
Thank you sir, it works now! :) Kryddan 261 — 9y
Ad

Answer this question