Hello, please can someone tell me what I have done wrong with line 16? I want it to loop the above soundtrack 10 times but it only plays once.
This is the error message: Workspace.Part.Script:18: attempt to call global 'loop' (a nil value)
Thank you.
BoolValue = script.Parent.Parent.EmergencyLight1.Toggle sound1=game.Workspace.Sound1 sound2=game.Workspace.Sound2 sound3=game.Workspace.Sound3 sound4=game.Workspace.Sound4 function onClick() if BoolValue.Value == false then BoolValue.Value = true print(BoolValue.Value) sound1:Play() wait(3) sound2:Play() wait(5) sound3:Play() loop(10) -- Why doesn't this loop? It just waits then plays the other sound wait(85) sound4:Play() else BoolValue.Value = false end end script.Parent.ClickDetector.MouseClick:connect(onClick)
I don't think (loop(10) is the right method)
Pre-set their "Looped" bool to true and play them, then play the fourth sound after the desired time.
You have never defined loop
. (Hence it is nil
; you are calling it with a value of 10; but you cannot call nil
, hence your error).
Why would this do anything in particular?
Sounds do not have any API to play them a certain number of times. You can loop using the Looped property but this does not let you configure a number of loops. You must manage that yourself, by stopping it after a certain amount of time, e.g., 10 * lengthofsound
seconds.
There is basicly no scripting to do it. You put on loop on the sound id. If you talking about something else please tell me.