local debris = game:GetService("Debris")
local character = script.Parent
local rootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:FindFirstChildOfClass("Humanoid")
local soundGroup = script.FootStepSounds
db = false
repeat wait(0.1) until humanoid
local function sounds()
local material = soundGroup:FindFirstChild(humanoid.FloorMaterial.Name)
if material and not material.Playing and not db then
local clone = material:Clone()
if humanoid.MoveDirection.Magnitude > 0 and not clone.Playing then
if clone and clone:IsA("Sound") then
clone.Parent = humanoid.RootPart
clone:Play()
clone.PlaybackSpeed = humanoid.WalkSpeed / 16
debris:AddItem(clone, clone.TimeLength)
db = true
delay(clone.TimeLength / 1.5, function()
db = false
end)
end
else
clone:Remove()
end
end
end
while task.wait() do
sounds()
end
1 Like
You should do :Destroy() rather than :Remove()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.