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

how can i make my script run at the beginning of the round?

so dude , i have a script that makes 1 out of 4 platforms disappear every 20 seconds , and i wanna know how can i make it start only when the round starts and end when the round ends pls help

script for the disappearing platform >

local platforms = workspace.PlatformsFolder --put all the platforms in a folder

    colors = { --table of colors
            BrickColor.new("Electric blue"), --Really red
            BrickColor.new("Really red"), --Really blue
            BrickColor.new("Bright yellow"), --Deep orange
            BrickColor.new("Lime green") 
            }
while true do
            local color = colors[math.random(1,#colors)] --index the table and get a random color with math.random
            print(color)
            for i,v in pairs (platforms:GetChildren()) do --get children returns a table of the children in the platforms folder. for i,v in pairs goes through this table
                if v:IsA("BasePart") then --check if value is a base part
                    if v.BrickColor == color then --if the color of the value is the same as the random color chosen then
                        v.CanCollide = false
                        v.Transparency = 1
                    else --if not
                        v.CanCollide = true
                        v.Transparency = 0
                    end
                end
            end
            wait(20) --wait however long in between color changes
        end

And the script for the round>

local roundLenght = 140
local intermissionLenght = 20
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.LobbySpawn
local GameAreaSpawn = game.Workspace.GameAreaSpawn

InRound.Changed:Connect(function()
    if InRound.Value == true then
        for , player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame -- teleports players in 
 --the middle of the map where the game begins

        end
    else
    for , player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            char.HumanoidRootPart.CFrame = LobbySpawn.CFrame--teleports back to lobby
        end
    end
end)

local function roundTimer()
    while wait() do
        for i = intermissionLenght, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value ="Intermission: ".. i .." seconds left!"
        end
        for i = roundLenght, 1, -1 do
            InRound.Value = true
            wait(1)

Should i also say the position of scripts? position of random disappearing platform script> StarterGui>ScreenGui>Frame>Script position of the round system script> ServerScriptService>Script

Pls help me

7 comments

0

Just disable your 'disappearing platforms' script and enable it via your 'round system' script when the time comes to teleport the players to your play area. Also, I don't prefer 'disappearing platform' script to be local and must be a Server/Normal script and to be kept in ServerScriptService to prevent exploitation.

0

oh ok , thanks for the info

0

hey but how can i enable it via my round system script when the time comes to teleport the players to my play area , could u pls help me with this and introduce the script in there cuz im a beginner and i dont rlly understand it , plsss help , post a comment with the introduced script pls

0

You can just add another variable for the other script (if you keep the other script in ServerScriptService), you can use 'script.Parent.[Your_Script_Name] to get the script. And then you can use the Disabled property of the script and change it via script, i.e., setting its value to true/false. Keep the script disabled first, and then change its bool property with the script.

0

Also, as you are in learning stage, you can search for videos of 'how to disable/enable script using another script in roblox'.

0

And the line you are confused with, you can add the line of disabling the script after Line 19, and enabling the script after Line 12.

0

ooh thanks alot , ill try my best :)

1 answer

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