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

The timed rounds script in my game doesn’t work can someone tell me what’s wrong?

Asked by 6 years ago

Hi, So I am making a survival game where the players (15 players are allowed in each server in case this is important) are in Jurassic World and they have to survive while the dinosaurs try to catch them. The way the game is set up is that there are two teams, the Tourists (survivors) and the Casualties (people who died). But here is where it gets a bit tricky, there technically three mini-rounds in each "round." The first lasts two minutes (120 seconds) and there are no dangers, the players can just walk around the park and look at the dinosaurs or find hiding spots or whatever. Then after the two minutes, the Dinosaurs "escape" out of their habitats/cages and the players have to try to avoid and or survive the dinosaurs from attacking and killing them, this round lasts 5 minutes (300 seconds). The final "round" is the same as the previous one except at the docks the two rescue boats appear and the players have to get to these boats to become safe, this round lasts 2 minutes (120 seconds). Every time a new mini round begins a GUI at the top appears saying what round it is (whether you can look around, have to run/survive, or if the boats appeared). There is also a quick 45-second intermission in between the end of the final mini-round and the beginning of a new game. The script below is the script that I made that I thought should make all of this happen but for some reason when I play the game, the background of the GUI that tracks the rounds shows up but the text doesn't, the box is empty. The bolded script (the part inside **) is the part that should make the GUI that announces who survived the previous round (all of the people on the Tourists team). That GUI should appear after the overall round/final mini-round ends and before the next Intermission begins but it also doesn't appear. Then finally the last part of the script, the italicized part (*), is what is supposed to make all of the players on the Casualties team change to be on the Tourists team during intermission and teleports them to the tourists spawn point but this doesn't work either. Can anyone tell me what I did wrong and help me fix it? Please comment below if you have any clarifying questions for me and I will respond as soon as I can. Thanks so much for all of your help, Skyraider5

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("Time")
local i = 15,0,-1
local a = 1
while a < 10 do
    while game.Players.NumPlayers < 1 do
        status.Value = "1 or more players are required to begin!"
        repeat wait(2) until game.Players.NumPlayers >= 1
    end
    status.Value = "Intermission... "..i 
   wait(.15)
   wait(1)
   status.Value = "Welcome To Jurassic World! Explore The Park!"
   wait(5)
   status.Value = "Emergency! Assests Out Of Containment! Get To Safety!"
   wait(10)
    status.Value = "The Rescue Boats Have Arrived! Get To The Docks!"
    wait(5)
    status.Value = "The Island Has Been Evacuated! All Known Survivors Rescued!"
    wait(1)
    **local sg = game.StarterGui("ScreenGui")
    sg.Parent = game.Players.LocalPlayer.PlayerGui
    local winnerGui = sg.SurvivorsPage.Frame("WinnersList")
    winnerGui.AnchorPoint = Vector2.new(0.5,0.5)
    winnerGui.Position = UDim2.new(0.5,0,0.5,0)
    local list = Instance.new("UIListLayout")
    list.Padding = UDim.new(0,0)
    list.Parent = winnerGui
    local survivors = game:GetService("Teams").Tourists:GetPlayers()
    for _,v in pairs(survivors) do
    local newLabel = sg.winnerGui("TextLabel")
    newLabel.Text = v.Name
    newLabel.Size = UDim2.new(1,0,0,20)
    newLabel.Parent = winnerGui
    end
    winnerGui.Size = UDim2.new(0,250,0,20*#survivors)
    winnerGui.Parent = sg
    wait(8) --time gui stays open
    sg:Destroy()**

    *--this part moves players from Casualties team to Tourists team:
    local dead = game:GetService("Teams").Casualties:GetPlayers()
    for _,v in pairs(dead) do
    v.Team = game:GetService("Teams").Tourists
    end*

0
OK I have a question for you. How are you counting your player? I dont even think you need to have that while loop in the with game.Players.NumPlayers. You are over complicating it. If there are no players then the game doesnt run anyway. However if you keep that while loop in thee you will have to write another script out to add a number inside of a NumberValue every time a player leaves or joins CrazyRoblots 13 — 6y
0
So I should take the whole loop out but I have done that but the primary problem still exists, the script doesn’t work. Do you know what I should do to fix it? Skyraider5 -21 — 6y
0
I just posted an answer. Tell me if it works CrazyRoblots 13 — 6y
0
Oh crap I see whats wrong. Its that you are pointing to startergui insstead of playergui. Is this in a local script or a server script CrazyRoblots 13 — 6y
View all comments (2 more)
0
A server script, should I change it to a local script instead? Skyraider5 -21 — 6y
0
So as I am understanding it, I need to use the last script in your answer in a local script and see if that works, correct? Skyraider5 -21 — 6y

1 answer

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

I know I posted the comment up top but try this and tell me what happens.. Take Out the following while loop. Make SURE TO ALSO TAKE OUT THE END OF THE WHILE LOOP TOO:

while game.Players.NumPlayers < 1 do
        status.Value = "1 or more players are required to begin!"
        repeat wait(2) until game.Players.NumPlayers >= 1
    end

**and change it to **

while true do

end

The whole thing will look like this

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("Time")
local i = 15,0,-1
local a = 1
while true do

     status.Value = "Intermission... "..i 
   wait(.15)
   wait(1)
   status.Value = "Welcome To Jurassic World! Explore The Park!"
   wait(5)
   status.Value = "Emergency! Assests Out Of Containment! Get To Safety!"
   wait(10)
    status.Value = "The Rescue Boats Have Arrived! Get To The Docks!"
    wait(5)
    status.Value = "The Island Has Been Evacuated! All Known Survivors Rescued!"
    wait(1)
    local sg = game.StarterGui:WaitForChild("ScreenGui")-- CHANGE ScreenGui IN THE QUOTES TO THE NAME OF YOUR SCREENGUI
    local CloneItem = sg:clone()
    CloneItem.Parent = game.Players.LocalPlayer.PlayerGui

    local winnerGui = sg.SurvivorsPage.Frame:WaitForChild("WinnersList")
    winnerGui.AnchorPoint = Vector2.new(0.5,0.5)
    winnerGui.Position = UDim2.new(0.5,0,0.5,0)
    local list = Instance.new("UIListLayout")
    list.Padding = UDim.new(0,0)
    list.Parent = winnerGui
    local survivors = game:GetService("Teams").Tourists:GetPlayers()
    for _,v in pairs(survivors) do
    local newLabel = sg.winnerGui("TextLabel")
    newLabel.Text = v.Name
    newLabel.Size = UDim2.new(1,0,0,20)
    newLabel.Parent = winnerGui
    end
    winnerGui.Size = UDim2.new(0,250,0,20*#survivors)
    winnerGui.Parent = sg
    wait(8) --time gui stays open
    CloneItem:Destroy()

    --this part moves players from Casualties team to Tourists team:
    local dead = game:GetService("Teams").Casualties:GetPlayers()
    for _,v in pairs(dead) do
    v.Team = game:GetService("Teams").Tourists
    end
wait(0.1)
end
0
I just updated the script. Let me know what happens CrazyRoblots 13 — 6y
0
Yes, That is correct. But I think this may work. Just keep me informed. I will be back on in a bit and check with you CrazyRoblots 13 — 6y
0
Ok I’ll try it both ways, local and regular just to make sure. I’ll probably be able to try it in like 15-20 minutes and I’ll let you know how it works. Skyraider5 -21 — 6y
0
Ok, so here is what happened. I put the script in and it worked in fixing the Gui that shows the round, that does work now but the problem is that the Winners Gui, the one that announces who survived the game, still doesn't show up after the "THE ISLAND HAS BEEN EVACUATED..." GUI and the players on the Casualties team still don't switch over to the Tourists team Skyraider5 -21 — 6y
View all comments (4 more)
0
Oh also, the rounds don’t repeat, once the ISLAND HAS BEEN EVACUATED... GUI appears it just stays on the screen when it should cause the intermission to start and the cycle to restart Skyraider5 -21 — 6y
0
Okay so I fixed the second Gui which is caled winnerslist to show up. But here is my issue, The way you have them wait statements set up is not going to work. Also you do know them wait statements are in seconds right? So in order the first wait statement will wait for .15 of a second. The second one will waiit 1 second third one will wait 5 seconds ETC. Were you trying to set them as Minutes? CrazyRoblots 13 — 6y
0
So as it stands right now your intermission will be 1.15 seconds CrazyRoblots 13 — 6y
0
Yeah I know they are in seconds I just put them in small increments for testing purposes, thanks for making sure though. Anyway, you said you did fix the script to work right? Skyraider5 -21 — 6y
Ad

Answer this question