When the game starts there are two or more players. If there is one player alive the player should get credits and return to the lobby. But instead of that the timer continues and the player won't get any credits. Any solutions?
Here is the script
view source
01 local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren() -- Make sure that your maps are in serverstorage. If you have more than just maps in serverstorage, the script might actually choose that.
02 local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
03 chosenmap:Clone().Parent = mapstorage
04 status.Value = "Loading Map.."
05 wait(3)
06 local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
07 for _, player in pairs (game.Players:GetPlayers()) do
08 if player and #spawns > 0 then
09 local torso = player.Character:WaitForChild('HumanoidRootPart')
10 local allspawns = math.random(1, #spawns)
11 local randomspawn = spawns[allspawns]
12 if randomspawn and torso then
13 table.remove(spawns, allspawns)
14 torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0))
15
16 local primary = game.ReplicatedStorage.Handgun -- CHANGE THIS TO WHATEVER ITEM YOU WANT TO GIVE THEM WHEN THEY ARE TELEPORTED. MAKE SURE IT IS IN REPLICATED STORAGE.
17 local newprimary = primary:Clone()
18 newprimary.Parent = player.Backpack
19
20 end
21 end
22 end
23 status.Value = "Be The Last Standing!"
24 if status.Value then
25 game.Workspace.Sound:Stop()
26 end
27 wait(4)
28 for i = 196,0,-1 do -- You can adjust the #196 to how long you want the round to last.
29 if i == 0 then
30 status.Value = "Time is up!"
31 wait(3)
32 break
33 end
34 wait(1)
35 if #_G.gameplayers == 1 then
36 for i, v in pairs(_G.gameplayers) do
37 if v ~= nil then
38 status.Value = v.." Won The Game!"
39 game.Players[v].leaderstats.Cash.Value = game.Players[v].leaderstats.Cash.Value + 15 -- The #15 will be how much credit or cash is awarded to the player if there was only one player teleported.
40 break
41 end
42
43 end
44 break
45 else
46 status.Value = i.."..Seconds Remaining!"
47 end
48 end
49 for i, player in ipairs(game.Players:GetPlayers()) do
50 if player.Character then
51 local hum = player.Character:FindFirstChild('Humanoid')
52 if hum then
53 hum.Health = 0
54 end
55 end
56 end
57 mapstorage:ClearAllChildren()
58
59 wait(5)
60 end

1 comment
Did you get this script from AlvinBlox? I remember watching some of his tutorials and this script is REALLY similar to one of his scripts. It might not be working because the script requires other separate scripts to handle the player tables. Did you set up the separate scripts?