Basically, i'm gonna make something thats called King Headless, He makes an evil laugh every 20 to 15 seconds, What do i need to do to make that possible?
while true do wait(0.5) script.Parent.EvilLaugh:Play() end
Please Write your examples in answers, i do not understand through comments.
while true do wait(math.random(15,20) script.Parent.EvilLaugh:Play() script.Parent.EvilLaugh.Ended:Wait() end
Hope This Helps!
To make your cooldown from 15-20 seconds you'll need to change the wait() time.
local sound = script.Parent:WaitForChild("EvilLaugh") while true do wait(17.5) -- average of 15 and 20 sound:Play() wait(sound.TimeLength) sound:Stop() end
The 'wait(sound.TimeLength)' bit will make it so that the sound will stop after it's done playing.
This is quite simple, you’re using the correct loop, but I’d use repeat
as it feels a little bit cleaner.
local EvilLaugh = script.Parent.EvilLaugh --//Get used to reference variables, they help juristically repeat wait(25) --// time between each “laugh”; before the next run. EvilLaugh:Play() wait(EvilLaugh.TimeLength) EvilLaugh:Stop() --// Extra precaution if the sound doesn’t stop until --// you should probably provide a conditional statement to break the loop as if something breaks have by the loop processing nothing forever.
Hope this helps!