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

How do i make these footstep sounds work?

So i am trying to make footstep sounds for walkspeeds but my script never changes to the other so if i start at 16 walk speed its that playback speed and it keeps all the time but with the 6 walkspeed its same what do i do

local char = script.Parent

delay(0, function()
	
	while wait() do
			if char.Humanoid.FloorMaterial == Enum.Material.Sand then
					if char.Humanoid.WalkSpeed == 16 then
						char.Head.Running.SoundId = "rbxassetid://134456884"
						char.Head.Running.Volume = 1
						char.Head.Running.PlaybackSpeed = 2.6
					elseif char.Humanoid.WalkSpeed == 6 then
						char.Head.Running.SoundId = "rbxassetid://134456884"
						char.Head.Running.Volume = 1
						char.Head.Running.PlaybackSpeed = 1.2
					end
				script.Parent.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
					if char.Humanoid.WalkSpeed == 16 then
						char.Head.Running.SoundId = "rbxassetid://134456884"
						char.Head.Running.Volume = 1
						char.Head.Running.PlaybackSpeed = 2.6
					elseif char.Humanoid.WalkSpeed == 6 then
						char.Head.Running.SoundId = "rbxassetid://134456884"
						char.Head.Running.Volume = 1
						char.Head.Running.PlaybackSpeed = 1.2
				end
			end)
		end
	end
end)

1 answer

✓ Accepted answer

What you're doing is checking to see if a player's WalkSpeed is 16, not if they're walking. In order to check if a player is currently moving, you can use the Humanoid.Running event to make a function. An example:

local Char = workspace.NPC

Char.Humanoid.Running:Connect(function(speed)
	if Char.Humanoid.FloorMaterial = Enum.Material.Sand then
		if speed > 0 then
			workspace.Sound:Play()
		elseif speed < 0 then
			workspace.Sound:Stop()
		end
	end
end)

2 comments

0

Sorry, I made an error. The Line 7 elseif statement should be <= 0 rather than < 0.

0

i would like to know how th speed works

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