Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(Answered) i need help with a math.random problem please help if possible,... ?

--im using math.random for sounds but the thing is the sound overlaps the other sound when playing, is there a way? --this is my script is there to make it where the math.random waits till the audio is over?

local sound = workspace["Sound"] --this is my sound from my workspace

while true do wait(math.random(1,7)) sound:Play() end

--if you don't get my question go into a roblox studio get a sound put this script in then put for math.random like to 1, and 4 or something so it overlaps so you can see my problem

1 answer

Nevermind guys i figured it out my self here is the script if you also need it

local sound = workspace.sound --for the sound just put your sound 


while true do -- creates a loop for math.random
	wait()
	if sound.Playing == false then -- this script is so it only works when it is playing
		wait(math.random(1,7))
		sound:Play()
	elseif sound.Playing == true then -- if it is playing then it does the print below
		print("Hello") --i just did this so it could do something so it works (you can just put something else if you want)
	
	end
	
end

This discussion is preserved as it was. New answers, comments, and votes are closed.