Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

--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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

Ad

Answer this question