Can't set humanoid walkspeed to an IntValue

I’ve been trying to change humanoid walkspeed to an intvalue found in replicatedstorage however it doesn’t seem to work and still uses the default walking speed (16)

local speed = game:GetService("ReplicatedStorage"):WaitForChild(Character.Name):WaitForChild("Speed")
--Localscript in StarterCharacterScripts.
local Character = script.Parent
while true do
  Character.Humanoid.WalkSpeed = speed.Value
end

Replace while true do with while speed.Changed:Wait() do.

Sadly doesn’t work, the character still spawns with default walking speed. (16)

They do because the value wasn’t changed yet.

Add a line to the top of the script:
local firstRun = true

Then, replace your while speed.Changed:Wait() do with while speed.Changed:Wait() or firstRun do

Then, add firstRun = false in the loop.

Tried it and it still doesn’t work.

local speed = game:GetService("ReplicatedStorage"):WaitForChild("Stats"):WaitForChild("WalkSpeed")
local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local firstRun = true


while speed.Changed:Wait() or firstRun do
	Humanoid.WalkSpeed = speed.Value
	firstRun = false
end

Okay, remove the firstRun stuff. Try while Character.Parent do and add a line at the end of the loop speed.Changed:Wait(). Add a line at the top of the script that says task.wait(0.5) (used to prevent replication failures).

1 Like

If you want it to run when it changes, use GetPropertyChangedSignal.

-- assuming this is all in the same script located in the character --
local Character = script.Parent
local speed = game:GetService("ReplicatedStorage"):WaitForChild(Character.Name):WaitForChild("Speed")
local humanoid = Character:WaitForChild("Humanoid")
local function update()
    humanoid.WalkSpeed = speed.Value
end
speed:GetPropertyChangedSignal("Value"):Connect(update)
update()
1 Like

Figured out it was a different script causing this, i don’t know why this sprint script is so buggy.

Wait this is a sprint script? All of this should be done in one script in that case.