Script that makes sound effects activate while you walk

while task.wait() do
	if script.Parent.Humanoid:GetState() == Enum.HumanoidStateType.Running then
		script.Parent.HumanoidRootPart.footstep1.TimePosition =0
		script.Parent.HumanoidRootPart.footstep1.Playing = true
		wait(0.75)
		script.Parent.HumanoidRootPart.footstep2.TimePosition =0
		script.Parent.HumanoidRootPart.footstep2.Playing = true
		wait(0.75)
	end
end

edit: I forgot to say what the issue is. The issue is that the sounds will play even when I’m not walking.

1 Like

What doesn’t work from your script? Do you get any errors?

The sound plays even when I’m not walking.

I wouldn’t just use a while loop for this, I would check when the State of the humanoid changes using StateChanged and run the rest of the script.

Example script:


local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

Humanoid.StateChanged:Connect(function(oldState, newState)
    if newState == Enum.HumanoidStateType.Running then
     --Run your code
     end
end)

now it just does a burst of footsteps at the beginning, but when I walk, it doesn’t do anything. Also this only works on a LocalScript, but I want it on server side.

You can go to RbxCharacterSounds and change the SoundIds there.

Tutorial:

You never turn the sounds off after turning them on. Add an else statement and write code to turn the sounds off

1 Like

I’ll try that tomorrow. I can’t right now because I’m on ipad.

1 Like