XIaineJoin Date: 2010-04-23 Post Count: 687 |
I want to have a five second pause between each loop of this sound. What can I add or change to make it do that?
local enabled = true
script.Parent.ClickDetector.MouseClick:connect(function()
if enabled == true then
if script.Parent.Sound.IsPlaying == false then
script.Parent.Sound:Play()
end
end
enabled = false
end)
-𝓧 |
|
|
After then maybe add wait(5)
but i dont understand what you want to do |
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
If the `Looped` Property of the Sound is true, the audio will play instantaneously.
Try dis.
local sound = script.Parent:WaitForChild("Sound");
script.Parent.ClickDetector.MouseClick:Connect(function()
if not sound.IsPlaying then
wait(5);
sound.Looped = false;
sound:Play();
end
end)
|
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
Or if you mean 5 secs in between -being able- to loop it(as in a cooldown), you can add a debounce.
local sound,db = script.Parent:WaitForChild("Sound"),false;
script.Parent.ClickDetector.MouseClick:Connect(function()
if not db then
db = true;
if not sound.IsPlaying then
sound.Looped = false;
sound:Play();
end
wait(5)
db = false;
end
end)
|
|
XIaineJoin Date: 2010-04-23 Post Count: 687 |
Neither of the scripts seemed to work as I need.
Basically how I need it to work is this:
Sound plays
Wait 5
Sound plays
Wait 5
Sound plays
Wait 5
Etc
Etc
Etc
-𝓧 |
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
You should use a `while` loop, then.
local sound = script.Parent:WaitForChild("Sound");
local connection;
connection = script.Parent.ClickDetector.MouseClick:Connect(function()
connection:Disconnect();
sound.Looped = false;
while wait(5) do
sound:Play();
sound.Stopped:Wait();
end
end)
R$33,025 |
|
XIaineJoin Date: 2010-04-23 Post Count: 687 |
Still didn't seem to work. I think all that script did was make it wait five seconds once, but then continued to loop itself without the five second pause inbetween
-𝓧 |
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
Seems like the `Stopped` event wasn't firing. Try this lol
local sound,db = script.Parent:WaitForChild("Sound"),false;
script.Parent.ClickDetector.MouseClick:Connect(function()
if not db then
db = true;
sound.Looped = false;
while wait(5) do
sound:Play();
repeat wait() until not sound.IsPlaying;
end
end
end)
R$33,025 |
|
XIaineJoin Date: 2010-04-23 Post Count: 687 |
Still does nothing :(
Output says this:
>Script 'Workspace.Zombie.Head.Sound Script', Line 3
-𝓧 |
|
XIaineJoin Date: 2010-04-23 Post Count: 687 |
Well, there's no ClickDetecter in the model so it's not really needed. But other than that, it doesn't say anything about why it's not pausing in between loops
-𝓧 |
|
GoulstemJoin Date: 2012-07-04 Post Count: 7177 |
"Well, there's no ClickDetecter in the model so it's not really needed. But other than that, it doesn't say anything about why it's not pausing in between loops"
.-.
If there's no ClickDetector why are you trying to DETECT FREAKIN CLICKSSSSSSS
|
|
XIaineJoin Date: 2010-04-23 Post Count: 687 |
It's a script I ripped from another model LOL
But the problem was, was that I had loop checked off in the sound part. After unchecking it, it works perfectly now. :]
Thank yoooouuuuu!
-𝓧 |
|