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

How can I make it wait 10 seconds before it plays the music?

Asked by
iHavoc101 127
5 years ago
local plr = game.Players.LocalPlayer
local char
local torso

local container = game.ReplicatedStorage:WaitForChild("CinderingBGM")
local settings = require(container:WaitForChild("Settings"))
local musicfolder = container:WaitForChild("MusicFolder")
local globalfolder = musicfolder:WaitForChild("GlobalMusic")
local zonesfolder = musicfolder:WaitForChild("MusicZones")
local servercount = container:WaitForChild("ObjectCount").Value

function GetMatchingCount() --objects can take some time to actually replicate to the client. make sure that the client sees the correct # of objects in the music folder before initializing the rest of the script
    local count = 0
    local function recurse(instance)
        for _,v in pairs(instance:GetChildren()) do
            count = count + 1
            recurse(v)
        end
    end
    recurse(musicfolder)
    if count == servercount then return true end
end

while not GetMatchingCount() do
    wait(.5)
end


function IsCleanRotation(v3values) --check to see whether the rotation is at clean 90 degree increments so we can use the more simplistic calculations for it
    for _,v in pairs(v3values) do
        if not (v%90 <= 0.01 or v%90 >= 89.99) then --why not just check for (v%90 == 0)? because rotations can suffer from floating point inaccuracies
            return false
        end
    end
    return true
end
0
Use the wait function, for example, wait(10) MasonJames136 21 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
wait(10)
local plr = game.Players.LocalPlayer
local char
local torso

local container = game.ReplicatedStorage:WaitForChild("CinderingBGM")
local settings = require(container:WaitForChild("Settings"))
local musicfolder = container:WaitForChild("MusicFolder")
local globalfolder = musicfolder:WaitForChild("GlobalMusic")
local zonesfolder = musicfolder:WaitForChild("MusicZones")
local servercount = container:WaitForChild("ObjectCount").Value

function GetMatchingCount() --objects can take some time to actually replicate to the client. make sure that the client sees the correct # of objects in the music folder before initializing the rest of the script
    local count = 0
    local function recurse(instance)
        for _,v in pairs(instance:GetChildren()) do
            count = count + 1
            recurse(v)
        end
    end
    recurse(musicfolder)
    if count == servercount then return true end
end

while not GetMatchingCount() do
    wait(.5)
end


function IsCleanRotation(v3values) --check to see whether the rotation is at clean 90 degree increments so we can use the more simplistic calculations for it
    for _,v in pairs(v3values) do
        if not (v%90 <= 0.01 or v%90 >= 89.99) then --why not just check for (v%90 == 0)? because rotations can suffer from floating point inaccuracies
            return false
        end
    end
    return true
end
Ad
Log in to vote
0
Answered by 5 years ago

Put in wait (10) before the place where the music starts playing

Answer this question