Hey Devs, I’ve been creating a punch that can play sound effects if the tool has touched a Humanoid
I would like a cooldown that plays 1 sound every few milliseconds to seconds.
I’ve tried to put on debounce but still, no luck.
Here’s the script:
script.Parent.Touched:Connect(function(Otherpart)
local humanoid = Otherpart.Parent:FindFirstChildWhichIsA("Humanoid")
local punch = false
if humanoid ~= nil then
if not punch then
punch = true
local randsound = math.random(1,5)
if randsound == 1 then
script.Parent.Sound.SoundId = "rbxassetid://9117969892"
script.Parent.Sound["Play sound"].Disabled = false
end
if randsound == 2 then
script.Parent.Sound.SoundId = "rbxassetid://9117969687"
script.Parent.Sound["Play sound"].Disabled = false
end
if randsound == 3 then
script.Parent.Sound.SoundId = "rbxassetid://3932506625"
script.Parent.Sound["Play sound"].Disabled = false
end
if randsound == 4 then
script.Parent.Sound.SoundId = "rbxassetid://9117969584"
script.Parent.Sound["Play sound"].Disabled = false
end
if randsound == 5 then
script.Parent.Sound.SoundId = "rbxassetid://9117969717"
script.Parent.Sound["Play sound"].Disabled = false
wait(1)
punch = false
end
end
end
end)
These if
functions control a script that plays the Sound
.
^
The white dot is the Sound
.
The cyan dot controls whether it plays the sound or not.
This is the script that is displayed as the cyan dot:
script.Parent:Play()
script.Parent.Ended:Connect(function()
script.Disabled = true
end)
The red dot is the script that is displayed above or is the script that randomizes the SoundEffects
.