Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 07:40 PM |
For an example go here /---place?id=176643993
Code:
h = game.Lighting.msg minigames = game.ServerStorage.Minigames:GetChildren() local count = 0 local function playerone() for _, player in ipairs(game.Players:GetPlayers()) do if player.InGame.Value == true then count = count + 1 if count == 1 then h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to last player..." for i,v in pairs(game.Players:GetPlayers()) do ingame = v:FindFirstChild("InGame") if ingame then if ingame.Value == true then v.leaderstats.Units.Value = v.leaderstats.Units.Value +25 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 end end end wait(3) gameChosenClone:Destroy() end end end return count end while true do if game.Players.NumPlayers > 1 then h.Value = "Minigame is currently being chosen, please wait." wait(3) ranGame = math.random(1, #minigames) gameChosen = minigames[ranGame] h.Value = "Minigame Chosen: " .. gameChosen.Name wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace wait(3) spawns = gameChosenClone.spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then v.Character:MoveTo(spawns[i].Position) v.InGame.Value = true end end end for i = 3, 1, -1 do h.Value = "Game starts in: " .. i wait(1) end if gameChosenClone.Name == "Dissapearing Plates - Made by Gladii" then timeTillGameEnds = 45 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end if gameChosenClone.Name == "Spleef - Made by Gladii" then timeTillGameEnds = 60 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to players who won..." for i,v in pairs(game.Players:GetPlayers()) do ingame = v:FindFirstChild("InGame") if ingame then if ingame.Value == true then v.leaderstats.Units.Value = v.leaderstats.Units.Value +10 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 end end end wait(3) gameChosenClone:Destroy() else h.Value = "Waiting for 1 more player..." end wait(1) end while true do wait() for i,v in pairs(game.Players:GetChildren()) do ingame = v:FindFirstChild("InGame") if v.Character.Humanoid.Health == 0 then if ingame then ingame.Value = false end end end end |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 11 Sep 2014 07:46 PM |
wow cool.
What's the error? |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 07:50 PM |
Dosn't end on 1 player left. In studio, it derped majorly. In server, not so much. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 11 Sep 2014 07:53 PM |
Unfortunately, there's not a good way at determining when a player dies.
if v.Character.Humanoid.Health == 0 then is one method, but there's also a way that involves the Humanoid's status, that fires an event when it dies.
game.Players.LocalPlayer.CharacterAdded:connect (function (char) char.Character.Humanoid.Died:connect (function () print "ya died" end) end)
I've found that both of these are pretty unreliable. |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 07:54 PM |
| Well. I can made it give the points to the players who won and not give point to the players who didn't. |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
cingwar73
|
  |
| Joined: 16 Aug 2009 |
| Total Posts: 358 |
|
|
| 11 Sep 2014 08:10 PM |
Try this, however I got confused at one point as to your organization style, and am expecting I misplaced a few ends, and I couldnt check if it worked on my own side, so if anything errors, please say so.
h = game.Lighting.msg ReallyIsIn = Instance.new("Model",game.Workspace) minigames = game.ServerStorage.Minigames:GetChildren() local count = #ReallyIsIn:GetChildren() local function playerone() if count == 1 then h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to last player..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +25 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 for i,cingwar in pairs(ReallyIsIn:GetChildren()) do cingwar:Destroy() --Better then ClearAllChildren k end end wait(3) gameChosenClone:Destroy() end return count end
while true do if game.Players.NumPlayers > 1 then h.Value = "Minigame is currently being chosen, please wait." wait(3) ranGame = math.random(1, #minigames) gameChosen = minigames[ranGame] h.Value = "Minigame Chosen: " .. gameChosen.Name wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace wait(3) spawns = gameChosenClone.spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then v.Character:MoveTo(spawns[i].Position) reallyin = Instance.new("StringValue",ReallyIsIn) reallyin.Name = v.Name end end end for i = 3, 1, -1 do h.Value = "Game starts in: " .. i wait(1) end if gameChosenClone.Name == "Dissapearing Plates - Made by Gladii" then timeTillGameEnds = 45 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end if gameChosenClone.Name == "Spleef - Made by Gladii" then timeTillGameEnds = 60 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to players who won..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +10 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 wait(3) gameChosenClone:Destroy() else h.Value = "Waiting for 1 more player..." end wait(1) end while true do wait() for i,v in pairs(game.Players:GetChildren()) do if v.Character.Humanoid.Health == 0 then ReallyIsIn:FindFirstChild(v.Name):Destroy() end end end end end end |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 08:15 PM |
No output. Dosn't work. Just says the default text at the top which is "Loading..." |
|
|
| Report Abuse |
|
|
cingwar73
|
  |
| Joined: 16 Aug 2009 |
| Total Posts: 358 |
|
|
| 11 Sep 2014 08:24 PM |
I moved a few ends, as I suspected.
h = game.Lighting.msg ReallyIsIn = Instance.new("Model",game.Workspace) minigames = game.ServerStorage.Minigames:GetChildren() local count = #ReallyIsIn:GetChildren() local function playerone() if count == 1 then h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to last player..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +25 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 for i,cingwar in pairs(ReallyIsIn:GetChildren()) do cingwar:Destroy() --Better then ClearAllChildren k end end wait(3) gameChosenClone:Destroy() end return count end end
while true do if game.Players.NumPlayers > 1 then h.Value = "Minigame is currently being chosen, please wait." wait(3) ranGame = math.random(1, #minigames) gameChosen = minigames[ranGame] h.Value = "Minigame Chosen: " .. gameChosen.Name wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace wait(3) spawns = gameChosenClone.spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then v.Character:MoveTo(spawns[i].Position) reallyin = Instance.new("StringValue",ReallyIsIn) reallyin.Name = v.Name end end end for i = 3, 1, -1 do h.Value = "Game starts in: " .. i wait(1) end if gameChosenClone.Name == "Dissapearing Plates - Made by Gladii" then timeTillGameEnds = 45 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end if gameChosenClone.Name == "Spleef - Made by Gladii" then timeTillGameEnds = 60 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone() end end h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to players who won..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +10 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 wait(3) gameChosenClone:Destroy() end end else h.Value = "Waiting for 1 more player..." end wait(1) end while true do wait() for i,v in pairs(game.Players:GetChildren()) do if v.Character.Humanoid.Health == 0 then ReallyIsIn:FindFirstChild(v.Name):Destroy() end end end |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 08:27 PM |
| Works but dosn't end the minigame when there is 1 player left. |
|
|
| Report Abuse |
|
|
cingwar73
|
  |
| Joined: 16 Aug 2009 |
| Total Posts: 358 |
|
|
| 11 Sep 2014 08:40 PM |
There wasnt a game clone set before/inside the playerone function, so I had it send the map to delete
h = game.Lighting.msg ReallyIsIn = Instance.new("Model",game.Workspace) minigames = game.ServerStorage.Minigames:GetChildren() local count = #ReallyIsIn:GetChildren() local function playerone(gcc) if #ReallyIsIn:GetChildren() <= 1 then h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to last player..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +25 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 for i,cingwar in pairs(ReallyIsIn:GetChildren()) do cingwar:Destroy() --Better then ClearAllChildren k end end end wait(3) gcc:Destroy() end end
while true do if game.Players.NumPlayers > 1 then h.Value = "Minigame is currently being chosen, please wait." wait(3) ranGame = math.random(1, #minigames) gameChosen = minigames[ranGame] h.Value = "Minigame Chosen: " .. gameChosen.Name wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace wait(3) spawns = gameChosenClone.spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then v.Character:MoveTo(spawns[i].Position) reallyin = Instance.new("StringValue",ReallyIsIn) reallyin.Name = v.Name end end end for i = 3, 1, -1 do h.Value = "Game starts in: " .. i wait(1) end if gameChosenClone.Name == "Dissapearing Plates - Made by Gladii" then timeTillGameEnds = 45 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone(gameChosenClone) end end if gameChosenClone.Name == "Spleef - Made by Gladii" then timeTillGameEnds = 60 for i = timeTillGameEnds, 1, -1 do h.Value = "Time left: " .. i wait(1) playerone(gameChosenClone) end end h.Value = "Round has ended!" wait(3) h.Value = "Giving Units to players who won..." for i,v in pairs(game.Players:GetPlayers()) do if ReallyIsIn:FindFirstChild(v.Name) then v.leaderstats.Units.Value = v.leaderstats.Units.Value +10 v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1 wait(3) gameChosenClone:Destroy() end end else h.Value = "Waiting for 1 more player..." end wait(1) end while true do wait() for i,v in pairs(game.Players:GetChildren()) do if v.Character.Humanoid.Health == 0 then ReallyIsIn:FindFirstChild(v.Name):Destroy() end end end |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 11 Sep 2014 08:47 PM |
| still dosn't end the game on 1 player left |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|