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.
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.