Ive been working on this script for about a day now and I have never worked with teams before and I was wondering if anyone could help me out a little bit. I kinda wanted to have 5 players on each team and when lets say someone on red team died it would give blue team 1 point and when one team reached 50 points it would end the game and give the people on blue team cash or something.
Heres the script ive gotten so far, this is my last wall that I have to get over... Other than data saving. Anyone care to help me out :)
I was thinking it would go before "Game time" starts.
local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("InfoValue") local mapstorage = game.Workspace:WaitForChild("MapStorage") local serverstorage = game:GetService("ServerStorage") local intTime = 5 local MapLoadTime = 3 local GameTime = 5 local RoundOver = 3 while true do -- Waiting for players to join while game.Players.NumPlayers < 2 do status.Value = "Waiting For Players!" repeat wait(2) until game.Players.NumPlayers >= 2 end -- Intermission for i = intTime, 0, -1 do status.Value = "Intermission: "..i wait(1) end -- Loading a map local mapsinserverstorage = game:GetService("ServerStorage").Maps:GetChildren() status.Value = "Loading Map..." wait(MapLoadTime) -- Map loading time status.Value = "Map Loaded!" wait(1) -- Map loaded time local chosemap = mapsinserverstorage[math.random(1, #mapsinserverstorage)] chosemap:Clone().Parent = mapstorage -- Teleporting players status.Value = "Pick Your Class!" local spawns = chosemap:WaitForChild("Spawns"):GetChildren() for _, player in pairs(game.Players:GetPlayers()) do if player and #spawns > 0 then local uppertorso = player.Character:WaitForChild("UpperTorso") local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] if randomspawn and uppertorso then table.remove(spawns, allspawns) uppertorso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0, 3, 0)) local classgui = game.StarterGui:FindFirstChild("ClassGUI"):Clone() classgui.Enabled = true classgui.Parent = player.PlayerGui wait(10) player.PlayerGui:FindFirstChild("ClassGUI"):Destroy() end end end -- Game time for i = GameTime, 0, -1 do status.Value = i.." Time Left!" if i == 0 then status.Value = "Round Over!" wait(RoundOver) -- Give players points for _, player in pairs(game.Players:GetPlayers()) do if player:FindFirstChild("leaderstats") then player.leaderstats.Presents.Value = player.leaderstats.Presents.Value + 5 end end break else end wait(1) end mapstorage:ClearAllChildren() wait() end
Thanks for your time. Even a YouTube tutorial would help.