I’m making a script that plays a sound every time the player touches the parts, but it doesn’t seem to work. I’ve rewritten the script in a few different ways but I still can get it to work. Any help would be highly appreciated.
-
What do you want to achieve?
I want the sound to play every time the player touches the parts -
What is the issue?
Sound isn’t playing
local sound = game:GetService("ReplicatedStorage"):WaitForChild("Sounds"):WaitForChild("DirtStep")
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Part") and v.Name == "Part" then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
sound:Play()
end
end)
v.TouchEnded:Connect(function(hit)
sound:Pause()
end)
end
end