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
01 | local char = script.Parent |
02 |
03 | delay( 0 , function () |
04 |
05 | while wait() do |
06 | if char.Humanoid.FloorMaterial = = Enum.Material.Sand then |
07 | if char.Humanoid.WalkSpeed = = 16 then |
08 | char.Head.Running.SoundId = "rbxassetid://134456884" |
09 | char.Head.Running.Volume = 1 |
10 | char.Head.Running.PlaybackSpeed = 2.6 |
11 | elseif char.Humanoid.WalkSpeed = = 6 then |
12 | char.Head.Running.SoundId = "rbxassetid://134456884" |
13 | char.Head.Running.Volume = 1 |
14 | char.Head.Running.PlaybackSpeed = 1.2 |
15 | end |
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:
01 | local Char = workspace.NPC |
02 |
03 | Char.Humanoid.Running:Connect( function (speed) |
04 | if Char.Humanoid.FloorMaterial = Enum.Material.Sand then |
05 | if speed > 0 then |
06 | workspace.Sound:Play() |
07 | elseif speed < 0 then |
08 | workspace.Sound:Stop() |
09 | end |
10 | end |
11 | end ) |