|
| 13 Feb 2012 10:08 PM |
local h = Instance.new("Hint",Workspace) local isOn = true
if game.Players.NumPlayers < 2 then isOn = false h.Text = "2 or more Players needed to play. Invite some friends!!!" end
if game.Players.NumPlayers >= 2 then isOn = true end
while isOn == true do h.Text = "There is more than 2 players in the server. Starting new game." wait(1) h.Text = "There is more than 2 players in the server. Starting new game.." wait(1) h.Text = "There is more than 2 players in the server. Starting new game..." wait(5) p = game.Players:GetChildren() for i = 1,#p do p[i].Character.Torso.CFrame = CFrame.new(0,0,0) end for x = 10, 0, -1 do h.Text = ""..x.."" wait(1) end local b = Instance.new("Part",Workspace) b.Size = Vector3.new(50,50,50) local p = Instance.new("Part",Workspace) p.Size = Vector3.new(50,50,50) function onTouch(hit) local human = hit.Parent:FindFirstChild("Humanoid") if (human ~= nil) then isOn = false wait(1) b:Destroy() p:Destroy() isOn = true pl = game.Players:GetChildren() for m = 1,#pl do pl[m].Charater.Torso.CFrame = Vector3.new(0,0,0) end end end end
game.Workspace.TouchMe.Touched:connect(onTouch)
It doesnt work. If there are more than 2 players in the server the script doesnt start running. Can anybody please help? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 13 Feb 2012 10:15 PM |
| That's because the code only runs once. And since right at the beginning the Players < 2 then the while loop doesn't run. Sure that's it, though, I am tired and going to bed :P |
|
|
| Report Abuse |
|
|
mage11561
|
  |
| Joined: 03 Sep 2008 |
| Total Posts: 13217 |
|
| |
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 13 Feb 2012 10:24 PM |
Try this.
local h = Instance.new("Hint", Workspace) h.Text = "2 or more players are needed to play. Invite some friends!!!" local plrs = #game.Players:GetPlayers() function updateGame() if plrs < 2 then h.Text = "2 or more Players needed to play. Invite some friends!!!" else for i = 1, 3 do h.Text = "There are more than 2 players in the server. Starting new game"..string.rep(".", i) end for i, v in pairs(game.Players:GetChildren()) do v.Character:MoveTo(Vector3.new(0,0,0)) end for x = 10, 1, -1 do h.text = x wait(1) end local b = Instance.new("Part",Workspace) b.Size = Vector3.new(50,50,50) local p = Instance.new("Part",Workspace) p.Size = Vector3.new(50,50,50) game.Workspace.TouchMe.Touched:connect(function(h) h = game.Players:GetPlayerFromCharacter(h.Parent) if h == nil then return end p:Destroy() b:Destroy() for i, v in pairs(game.Players:GetChildren()) do v.Character:MoveTo(Vector3.new(0,0,0)) end end) end end function updatePlrCnt() plrs = #game.Players:GetPlayers() updateGame() end game.Players.PlayerAdded:connect(updatePlrCnt) game.Players.PlayerRemoving:connect(updatePlrCnt)
---------- ~pwnedu46, wiki writer~
|
|
|
| Report Abuse |
|
|
|
| 13 Feb 2012 10:25 PM |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Can you show me how and where I should put it? |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2012 10:26 PM |
| Forget that post above. I was sapose to ask the person before you |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2012 10:50 PM |
@pwnedu46
the connection lines are both the same. which is which? |
|
|
| Report Abuse |
|
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 14 Feb 2012 03:36 PM |
The connections are similar, but not the same. They both call the same function, but are fired by different events. The logic applies in both situations, so it's easier and more effective to have the whole thing handled by one function.
---------- ~pwnedu46, wiki writer~ |
|
|
| Report Abuse |
|
|
|
| 15 Feb 2012 09:33 PM |
| How would you make this so it resets when all of the players have died? |
|
|
| Report Abuse |
|
|