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

Number value won't change the walkspeed value?

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.

1 comment

0

Suggestion: You should change everything to where the walkspeed = movespeed.Value. and remove the value part to the reference of movespeed

1 answer

✓ Accepted answer
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)

1 comment

2

Thank you sir, it works now! :)

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