Changes humanoid's WalkSpeed to 0 but player can still walk

I’m making a part that when it’s touched by a player, the player’s WalkSpeed is set to 0. I noticed that the player could still move and added a print after changing it to 0 and it printed “0.” I’m confused on why the player can still move.

local hasHeard = false

	if hit.Parent:FindFirstChild("Humanoid") and hasHeard == false then
		local character = hit.Parent
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		character.Humanoid.WalkSpeed = 0
		hasHeard = true

Are you doing it from the client? A client cannot change other humanoids walkspeeds, other than their own.

1 Like

No, I used a server script to change it, not a local script.

Well, that’s strange. I pasted the script in a Part and it worked for me.

1 Like

In my opinion, “and hasHeard == false then” is useless, just do “and not hasHeard then”

also, it must be:

local player = game.Players:GetPlayerFromCharacter(character)

add this after the player variable:

if player then
character.Humanoid.WalkSpeed = 0
hasHeard = true

i hope it helps :slight_smile:

1 Like

Since the client has network ownership of their character, you can’t change their walk speed unless you do it on the client or change network ownership of the character. I’d recommend firing a remote to the client causing them to change their speed or, you could change network ownership of the character but, there will be a noticeable amount of latency therefore, I’d recommend firing a remote to the client.


THANK YOU SO MUCH. This exact problem was happening to me and then after about 3 days I found this post and it helped me figure it out!