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: If All players are dead...

Previous Thread :: Next Thread 
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 08:18 PM
I have a game script, which is currently time based. I wan't it to be a "player is living" based.

If all the players who are playing die, THEN the game ends, not when the time runs out. I tried a table but it failed.

Heres the script:

while true do
local m = math.random(1,1)
local player = game.Players:GetPlayers()
for i = 1, #player do
msg = player[i].PlayerGui.Status.StatusText


if m == 1 then
local Spawn = game.Workspace.Spawn.Position
msg.Text = "Intermission"
wait(10)
msg.Text = "Game in Progress"
player[i].Character:MoveTo(Spawn) --Vector3.new(-101, 4.8, -146)
game.Lighting.Zombies:clone().Parent = game.Workspace
wait(30)
player[i].Character.Humanoid.Health = 0
end
end
end
Report Abuse
Drenkus is not online. Drenkus
Joined: 03 May 2009
Total Posts: 2380
28 Apr 2012 08:31 PM
First you'd need a value to tell whether the player is dead or not, then a loop.
Next a function to check when the player is dead, and to change the previous value with that function.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 08:34 PM
What?
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 08:35 PM
Ok so

while true do
function playerDead(player)
if player.Dead.Value = true then
--game ends
else
-do nothing
end

Like that?
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 08:47 PM
Bump
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 09:01 PM
Ok, so I tried this, but it doesn't work:

while true do
local m = math.random(1,1)
local player = game.Players:GetPlayers()
for i = 1, #player do
msg = player[i].PlayerGui.Status.StatusText


if m == 1 then
local Spawn = game.Workspace.Spawn.Position
player[i].Dead.Value = false
msg.Text = "Intermission"
wait(10)
msg.Text = "Game in Progress"
player[i].Character:MoveTo(Spawn) --Vector3.new(-101, 4.8, -146)
game.Lighting.Zombies:clone().Parent = game.Workspace
while wait() do
if player[i].Dead.Value = true then
player[i].Character.Humanoid.Health = 0
end
end
end
end
end
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 09:19 PM
Seriously.... I need some freaking help
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
28 Apr 2012 09:30 PM
Omg... This is rediculous. The help on this website is outrageous.... >:(
Report Abuse
callmeduck2 is not online. callmeduck2
Joined: 18 Jan 2010
Total Posts: 2804
28 Apr 2012 10:06 PM
any output?
and btw, thanks for telling me about the values in roblox parts.. i actually had to use that :P

site.Players.callmeduck2.PostCount.Value=site.Players.callmeduck2.PostCount.Value+1
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
29 Apr 2012 07:55 AM
Haven't checked. I will later, gotta go to church -_-

And your welcome, happy to help :D
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 07:58 AM
No.

Its not that hard look.

Make a script that insert a bool.

a = Instance.new("BoolValue", game.Players.LocalPlayer)
a.Value = false
a.Name = "Dead"

died()
game.Players.LocalPlayer.Dead.Value = true
end

game.Players.LocalPlayer.Character.Humanoid.Died:connect(died)

--another script, your game script

while true do
wait(1)
stopgame = true
for i,v in pairs(game.Players:GetPlayers()) do
if v.Dead.Value == false then
stopgame = false
end
if stopgame then
--use stuff here to stop the game, every player died!
end
end
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
29 Apr 2012 07:59 AM
Actually. I'll get it now. It says:

Workspace.MinigameScript:17: 'then' expected near '='

Not sure why it's doing this, I think the line is correct:

if player[i].Dead.Value = true then

Dead is a boolean so I think that should work :\
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 07:59 AM
math.random(1,1)? What a nonsense... xD
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:00 AM
..

Its == for if's, not =

= Sets things
== Makes a bool of something.

(Like
a = true
b = true
if a == b then

(a = b, so a == b is true, so if true then, code runs :))
)
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
29 Apr 2012 08:01 AM
@jobro

I get this:

Workspace.MinigameScript:7: 'eof' expected near 'end'
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:02 AM
You miss an end.

Check your code.
function() needs an end
if needs an end
do needs an end.
Report Abuse
DeVinci is not online. DeVinci
Joined: 21 Jul 2010
Total Posts: 338
29 Apr 2012 08:04 AM
Derp... I knew that XD

But when all the players die, the script stops working. Heres the script:

while true do
local m = math.random(1,1)
local player = game.Players:GetPlayers()
for i = 1, #player do
msg = player[i].PlayerGui.Status.StatusText


if m == 1 then
local Spawn = game.Workspace.Spawn.Position
player[i].Dead.Value = false
msg.Text = "Intermission"
wait(10)
msg.Text = "Game in Progress"
player[i].Character:MoveTo(Spawn) --Vector3.new(-101, 4.8, -146)
game.Lighting.Zombies:clone().Parent = game.Workspace
while wait() do
if player[i].Dead.Value == true then
player[i].Character.Humanoid.Health = 0
end
end
end
end
end
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:44 AM
Define spawn.
Report Abuse
callmeduck2 is not online. callmeduck2
Joined: 18 Jan 2010
Total Posts: 2804
29 Apr 2012 08:48 AM
@ both of you
"You miss an end." I'm pretty sure eof means you have an EXTRA end somewhere. If your missing one it wil tell you 'end expected to close function/if/repeat/etc at line whatever"


site.Players.callmeduck2.PostCount.Value=site.Players.callmeduck2.PostCount.Value+1
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:50 AM
Lets just say there is something off with the ends.

eof = End Of Function
Report Abuse
callmeduck2 is not online. callmeduck2
Joined: 18 Jan 2010
Total Posts: 2804
29 Apr 2012 08:52 AM
:3 as long as im right hahaha jk. But yea it looks good to me now, with the ends and stuff. + jobro, he did define spawn. :)

site.Players.callmeduck2.PostCount.Value=site.Players.callmeduck2.PostCount.Value+1
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:54 AM
Phail.
Report Abuse
callmeduck2 is not online. callmeduck2
Joined: 18 Jan 2010
Total Posts: 2804
29 Apr 2012 08:55 AM
phail in what way? I just woke up like an hour ago

site.Players.callmeduck2.PostCount.Value=site.Players.callmeduck2.PostCount.Value+1
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:56 AM
Spawn is defined, overlooked that.
Report Abuse
callmeduck2 is not online. callmeduck2
Joined: 18 Jan 2010
Total Posts: 2804
29 Apr 2012 08:59 AM
oh yea. I thought you were phailing me. I was about be all like " Oh hayl no boi" :D

site.Players.callmeduck2.PostCount.Value=site.Players.callmeduck2.PostCount.Value+1
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