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

How to make server roundsystem script reliably see workspace children?

Asked by 3 years ago
Edited 3 years ago

After 2 players join session, Roundsystem script fails to accurately see whats inside Workspace causing dead servers due to the script not continuing to run.

I've tried pcall but that causes specific levels to repeatedly run.

This is where it errors out due to the fact that it cant see jack in workspace unless there's only 1 player in the server.: line 51

"game.Workspace.WorldPartsBin.AC:Remove() --Ends the game"

while true do
    wait(5)
    game.Workspace.Terrain:FillBlock(game.Workspace.MainMenu.WaterBlock.CFrame, game.Workspace.MainMenu.WaterBlock.Size, Enum.Material.Water)
    local Waiterio = game.Workspace.StartSpawn
    local m = math.random(1,1)
    local player = game.Players:GetPlayers()
    for i = 1, #player do 
        msg = Instance.new("Message") 
        msg.Parent = nil

        if m == 1 then 
            wait(15)
            msg.Parent = game.Workspace 
            msg.Text = "Choosing Game." 
            wait(1)
            msg.Text = "The Game is..."
            wait(3)
            msg.Text = "Aquatic Conundrum" 
            wait(2)
            msg.Text = "Loading Game"
            wait(1)
            msg.Text = "Warning: Sinking Sand"
            wait(1.5)
            msg:remove()
            for _,v in pairs(game.Players:GetPlayers())do
                game.Lighting.SunRays.Enabled = true
                game.Lighting.SunRays.Intensity = 0.152
                game.Lighting.SunRays.Spread = 0.402
                game.Lighting.Ambient = Color3.fromRGB(145, 144, 149)
                game.Lighting.Brightness = 2
                game.Lighting.OutdoorAmbient = Color3.fromRGB(145, 144, 149)
                minutesAfterMidnight = 396
                game.Lighting:SetMinutesAfterMidnight (minutesAfterMidnight)
                game.Lighting.GeographicLatitude = 339.8
                game.Lighting.ExposureCompensation = 0.39
                game.Lighting.FogColor = Color3.fromRGB(58, 69, 129)
                game.Lighting.FogEnd = 300
                game.Lighting.FogStart = 30
                game.Workspace.Skyboxes.AC:clone().Parent = game.Lighting
                game.Lighting.Levels.AC:clone().Parent  = game.Workspace.WorldPartsBin
                script.Parent.ACRoundSystem.Disabled = false
                msg:remove() 
                wait(45)
                for _, player in pairs(game.Players:GetChildren()) do
                    local char = player.Character
                    char.HumanoidRootPart.CFrame = Waiterio.CFrame
                    char.HumanoidRootPart.Anchored = true
                    char.HumanoidRootPart.Anchored = false

                    script.Parent.ACRoundSystem.Disabled = true
                    game.Workspace.WorldPartsBin.AC:Remove() --Ends the game
                    game.Lighting.AC:Remove() --Removes Skybox
                    game.Lighting.SunRays.Enabled = false
                    game.Lighting.Ambient = Color3.fromRGB(73, 77, 86)
                    game.Lighting.Brightness = 0
                    game.Lighting.OutdoorAmbient = Color3.fromRGB(73, 77, 86)
                    minutesAfterMidnight = 1037
                    game.Lighting:SetMinutesAfterMidnight (minutesAfterMidnight)
                    game.Lighting.GeographicLatitude = 343
                    game.Lighting.ExposureCompensation = 0
                    game.Lighting.FogEnd = 99999
                    game.Lighting.FogStart = 99999
                    wait(0.1)
                end
            end
        end

Answer this question