Server not listening to localscript changing value?

I havea script that changes the player humanoid to an intvalue. It works. However when i try to change the value into something else, it only updates on replicatedstorage and not the humanoid walkspeed.

--SERVERSCRIPT
local Character = script.Parent
local speed = game:GetService("ReplicatedStorage"):WaitForChild("Stats"):WaitForChild(Character.Name):WaitForChild("WalkSpeed")
local humanoid = Character:WaitForChild("Humanoid")
while true do
	humanoid.WalkSpeed = speed.Value
end
--LOCALSCRIPT
Mouse.KeyDown:Connect(function(Key) 
	if Key == "c" then
		Anim2:Play()
		Humanoid.HipHeight = -1.1
		Speed.Value = Speed.Value - 12
	end  
end)
Mouse.KeyUp:Connect(function(Key)
	if Key == "c" then
		Anim2:Stop()
		Humanoid.HipHeight = 0
		Speed.Value = Speed.Value + 12
	end
end)

Please note that THE value DOES change on replicatedstorage but it doesn’t change on humanoid walkspeed.

The server won’t see the changes, instead of using a value you need to use RemoteEvents.

1 Like

RemoteEvents would cause too much delay no?
and it’s a local-based script movement so i don’t really want any delays.

No, they only have delays because of ping. But any time a LocalScript communicates with the server, even the way you are using (assuming it worked) there would be a delay for ping. That’s just the nature of communication. And yeah, you’ll probably get delays.

If possible, set the WalkSpeed directly in the LocalScript. It might not work that way, I don’t remember though. For some things the client is given authority to manage to prevent delays like you mention, WalkSpeed might be one of them.

1 Like

I might try changing the walkspeed default to intvalue on localscript instead.
On the side note of remote events, Do i change the value like this?

--LOCALSCRIPT
ReplicatedStorage.Crouch:FireServer(12)
--SERVERSCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage")

ReplicatedStorage.Crouch.OnServerEvent:Connect(function(speed)
	Speed.Value = Speed.Value - speed
end)

Pretty close. Just change this line to include player.

ReplicatedStorage.Crouch.OnServerEvent:Connect(function(player, speed)

player is automatically provided by the event, followed by whatever data you sent over.