i the GUI does not count how much time is left and i do not have the wait time?
-- Difine variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder = ServerStorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLenght = 50
local Reward = 25
-- Game Loop
while true do
01 | Status.Value = "Waiting for enough players" |
03 | repeat wait( 1 ) until game.Players.NumPlayers > = 2 |
05 | Status.Value = "Intermission" |
11 | for i, player in pairs (game.Players:GetPlayers()) do |
13 | table.insert(plrs,player) |
19 | local AvailableMaps = MapsFolder:GetChildren() |
21 | local ChosenMap = AvailableMaps [ math.random( 1 ,#AvailableMaps) ] |
23 | Status.Value = ChosenMap.Name.. " Chosen" |
25 | local ClonedMap = ChosenMap:Clone() |
26 | ClonedMap.Parent = workspace |
30 | local SpawnPoints = ClonedMap:FindFirstChild( "SpawnPoints" ) |
32 | if not SpawnPoints then |
33 | print ( "SpawnPoints not found!" ) |
36 | local AvailableSpawnPoints = SpawnPoints:GetChildren() |
38 | for i, player in pairs (plrs) do |
40 | character = player.Character |
45 | character:FindFirstChild( "HumanoidRootPart" ).CFrame = AvailableSpawnPoints [ 1 ] .CFrame |
46 | table.remove(AvailableSpawnPoints, 1 ) |
50 | local Sword = ServerStorage.Sword:Clone() |
51 | Sword.Parent = player.Backpack |
53 | local GameTag = Instance.new( "BoolValue" ) |
54 | GameTag.Name = "GameTag" |
55 | GameTag.Parent = player.Character |
end
01 | Status.Value = "Get ready to play!" |
05 | for i = GameLenght, 0 ,- 1 do |
07 | for x, player in pairs (plrs) do |
10 | character = player.Character |
15 | if character:FindFirstChild( "GameTag" ) then |
17 | print (player.Name.. " is still in the game!" ) |
21 | print (player.Name.. " has been removed!" ) |
26 | print (player.Name.. " has been removed!" ) |
30 | Status.Value = "There are " ..i.. " seconds remaining, and " ..#plrs.. " players left" |
34 | Status.Value = "The winner is " ..plrs [ 1 ] .Name |
35 | plrs [ 1 ] .leaderstats.Cash.Value = plrs [ 1 ] .leaderstats.Cash.Value + Reward |
37 | elseif #plrs = = 0 then |
38 | Status.Value = "Nobody won!" |
41 | Status.Value = "Time up!!" |
50 | for i, player in pairs (game.Players:GetPlayers()) do |
51 | character = player.Character |
56 | if character:FindFirstChild( "GameTag" ) then |
57 | character.GameTag:Destroy() |
60 | if player.Backpack:FindFirstChild( "Sword" ) then |
61 | player.Backpack.Sword:Destroy() |
64 | if character:FindFirstChild( "Sword" ) then |
65 | character.Sword:Destroy() |
70 | player:LoadCharacter() |
75 | Status.Value = " Game Ended" |