So, I have this script inside a part called SoundPlayerOne:
local part = script.Parent
part.Touched:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
wait(1)
local sound = Instance.new("Sound")
sound.Parent = part
sound.Looped = true
sound.Playing = true
sound.Volume = 1
sound.SoundId = "rbxassetid://178276804"
wait(1)
end
end)
Basically, it makes a Sound and puts it into SoundPlayerOne. There is a problem though, when it gets touched, it inserts 5 sounds into the part because of Roblox physics. I've tried making a version of this script with debounce but it just doesn't work.
How do I make a script where, when a certain amount of children is reached (2 or more in my case); it will delete them until there is one.
If you have an alternative way (i.e. debounce, which I can't seem to get to work) then feel free to answer with that method. :-)

1 comment
Thanks! I'll try and improve my scripting skills with this! #ACCEPTED