generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Ending Game When Players Dead

Previous Thread :: Next Thread 
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:16 PM
local Alive = {}
local GameActive = false

function PlayerDied(Player)
if Alive[Player.Name] then
Alive[Player.Name] = false
end
end

function SetPlayersAlive()
for _, v in pairs(game.Players:GetPlayers()) do
if v.Character and v.Character:FindFirstChild("Humanoid") and not GameActive then
Alive[v.Name] = true
v.Character.Humanoid.Died:connect(function() PlayerDied(v) end)
end
end
end

function AllPlayersDead()
for _, v in pairs(Alive) do
if v then return false end
end
return true
end

game.Players.PlayerRemoving:connect(function(player)
PlayerDied(player)
end)
while true do
wait(2)
msg = Instance.new("Hint")
msg.Parent = game.Workspace
msg.Text = "Game Starting In 30"
wait(1)
msg.Text = "Game Starting In 29"
wait(1)
msg.Text = "Game Starting In 28"
wait(1)
msg.Text = "Game Starting In 27"
wait(1)
msg.Text = "Game Starting In 26"
wait(1)
msg.Text = "Game Starting In 25"
wait(1)
msg.Text = "Game Starting In 24"
wait(1)
msg.Text = "Game Starting In 23"
wait(1)
msg.Text = "Game Starting In 22"
wait(1)
msg.Text = "Game Starting In 21"
wait(1)
msg.Text = "Game Starting In 20"
wait(1)
msg.Text = "Game Starting In 19"
wait(1)
msg.Text = "Game Starting In 18"
wait(1)
msg.Text = "Game Starting In 17"
wait(1)
msg.Text = "Game Starting In 16"
wait(1)
msg.Text = "Game Starting In 15"
wait(1)
msg.Text = "Game Starting In 14"
wait(1)
msg.Text = "Game Starting In 13"
wait(1)
msg.Text = "Game Starting In 12"
wait(1)
msg.Text = "Game Starting In 11"
wait(1)
msg.Text = "Game Starting In 10"
wait(1)
msg.Text = "Game Starting In 9"
wait(1)
msg.Text = "Game Starting In 8"
wait(1)
msg.Text = "Game Starting In 7"
wait(1)
msg.Text = "Game Starting In 6"
wait(1)
msg.Text = "Game Starting In 5"
wait(1)
msg.Text = "Game Starting In 4"
wait(1)
msg.Text = "Game Starting In 3"
wait(1)
msg.Text = "Game Starting In 2"
wait(1)
msg.Text = "Game Starting In 1"
wait(1)
msg.Text = "Teleporting"
target = CFrame.new(56.5, 97.6, -186.5)
for i, player in ipairs(game.Players:GetChildren()) do
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
end
wait(2)
msg:remove()
SetPlayersAlive()
repeat wait() until AllPlayersDead()
wait(50)
end



What is wrong with this script?
Ignore all the "Messages"
I need to know what is wrong with the function or if i need to move it.
I want the script to end and start over when ALL the players are dead. Is there a way to do that?
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:21 PM
Please help :C!
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:27 PM
Bump
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
29 Jan 2012 10:30 PM
while true do
wait(2)
msg = Instance.new("Hint")
msg.Parent = game.Workspace

--[[ I'm also changing this
msg.Text = "Game Starting In 30"
wait(1)
msg.Text = "Game Starting In 29"
wait(1)
msg.Text = "Game Starting In 28"
wait(1)
msg.Text = "Game Starting In 27"
wait(1)
msg.Text = "Game Starting In 26"
wait(1)
msg.Text = "Game Starting In 25"
wait(1)
msg.Text = "Game Starting In 24"
wait(1)
msg.Text = "Game Starting In 23"
wait(1)
msg.Text = "Game Starting In 22"
wait(1)
msg.Text = "Game Starting In 21"
wait(1)
msg.Text = "Game Starting In 20"
wait(1)
msg.Text = "Game Starting In 19"
wait(1)
msg.Text = "Game Starting In 18"
wait(1)
msg.Text = "Game Starting In 17"
wait(1)
msg.Text = "Game Starting In 16"
wait(1)
msg.Text = "Game Starting In 15"
wait(1)
msg.Text = "Game Starting In 14"
wait(1)
msg.Text = "Game Starting In 13"
wait(1)
msg.Text = "Game Starting In 12"
wait(1)
msg.Text = "Game Starting In 11"
wait(1)
msg.Text = "Game Starting In 10"
wait(1)
msg.Text = "Game Starting In 9"
wait(1)
msg.Text = "Game Starting In 8"
wait(1)
msg.Text = "Game Starting In 7"
wait(1)
msg.Text = "Game Starting In 6"
wait(1)
msg.Text = "Game Starting In 5"
wait(1)
msg.Text = "Game Starting In 4"
wait(1)
msg.Text = "Game Starting In 3"
wait(1)
msg.Text = "Game Starting In 2"
wait(1)
msg.Text = "Game Starting In 1"
wait(1)
]]

for i = 30, 1, -1 do
msg.Text = "Game Starting In "..i
wait(1)
end

msg.Text = "Teleporting"
target = CFrame.new(56.5, 97.6, -186.5)
for i, player in ipairs(game.Players:GetChildren()) do
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
end
SetPlayersAlive()
GameActive = true
wait(2) --Moved a few things around down here, and added the GameActive parts
msg:remove()
repeat wait() until AllPlayersDead()
GameActive = false
wait(5) -- intermission time
end
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:33 PM
ty i will see if this works right now :D
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:35 PM
omg it works :DDD!! I can still add to the while true loop right?
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:37 PM
would i add things on after the

repeat wait() until AllPlayersDead()

???
Report Abuse
harbar565 is not online. harbar565
Joined: 05 Nov 2010
Total Posts: 67
29 Jan 2012 10:44 PM
ok figured it all out.. thank you !
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image