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

How can you detect walkspeed for humanoid and then do a thing?

I was trying this for a couple of hours and I still coulden't fix this bug, Maybe someone knows how? Here's my script:


local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local humanoid = Character:WaitForChild('Humanoid')

local run = workspace.Run2


humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
   if humanoid.WalkSpeed == 0 then
	        run:Stop()
	    end
	end)


1 answer

You can use the GetPropertyChangedSignal, which will fire an event each time the humanoid's walkspeed is changed.

EDIT: from what i can see, you're tried to access the humanoid incorrectly. since this is a localscript (i hope), you should be able to access the character's humanoid through player.Character.

local plr = game:GetService('Players').LocalPlayer
repeat wait() until plr and plr.Character and plr.Character:FindFirstChild('Humanoid')
local humanoid = plr.Character.Humanoid

local run = workspace.Run2

humanoid:GetPropertyChangedSignal('WalkSpeed'):Connect(function()
	if humanoid.WalkSpeed == 0 then
		run:Stop()
	end
end)

8 comments

0

Sorry, but the script didn't work...

0

can you provide more of your first script? maybe you did something else wrong?

0

I edited the question

0

okay, i made an edit as well. let me know if it works.

0

Still doesn't work, and I think that on local humanoid you needed to replace player with plr because you named it that way.

0

what are you doing to change the humanoid's walkspeed? what are you trying to get from this script?

0

So, whenever he runs he makes a sound of him running (That's a diffrent script), but when he stops running, the sound doesn't stop.

0

you can stop the run sound on that same script

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