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 » Scripters
Home Search
 

Re: Help Making a Last One Alive script

Previous Thread :: Next Thread 
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 04:56 PM
How would I make a like a scan script. I will number it so it's easier to understand what I'm trying to do.

1. A Round is Seleceted [I did this already]
2. If the round is FFA, Then get number of players.
3. Each time a player dies that was scanned, remove 1 from the number of players left.
4. If number of players is 1 then get that last player and award them
5. End Round [I can do that]

I have no idea how to go with this.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 05:03 PM
I didn't test this, but I think this should help you.
Call this function when the round starts, and it will return a table

function createPlayerWatch()
local players = {}
local self = {}
function self:GetAlive()
local p = {}
for player in pairs(players) do
table.insert(p,player)
end
return p
end
for _,v in pairs(game.Players:GetPlayers()) do
if v.Character then
local humanoid = v.Character:findFirstChild("Humanoid")
if humanoid and humanoid.Health > 0 then
players[v] = true
humanoid.Died:connect(function ()
players[v] = nil
end)
end
end
end
game.Players.PlayerRemoving:connect(function (p)
if players[p] then
players[p] = nil
end
end)
return self
end

For example:

local players = createPlayerWatch()

while players:GetAlive() > 1 do
print(players:GetAlive(),"players left")
wait(1)
end
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 05:07 PM
@Clone

I tested it and it gave me a error

"attempt to compare number with table"
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 05:08 PM
Oh.

Change it to #players:GetAlive() > 1 sorry lol.



Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 05:12 PM
Nice, But I'm wondering how I would be able to test this in studio, Will this work if I create a server in studio [like test clients]
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 05:15 PM
Heres a handy function:

function isPlaySolo()
return game.JobId == ""
end
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 05:20 PM
@Clone

I'm stupid but.

What does that do, I've never seen a function like it.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 05:29 PM
game.JobId is basically a GUID that uniquely identifies a roblox game instance.
It only gets set if an actual game server is running.

local isPlaySolo = (game.JobId == "")
print(isPlaySolo)
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 06:03 PM
@Clone

The print is weird, it says stuff like

"table: 178D4A08 players left"
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:03 PM
Once again, change it to #players:GetAlive()
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 06:09 PM
@Clone

So if I wanted the game to end with 1 player do I like...

while wait() do
if script.Parent.players_left.Value == 1 then -- checks for 1 player
awardplayer() -- awards the last person
Timer = 0 -- If timer is at "0" then round ends and starts a new round.
respawnall() -- a function that respawns all players
end
end
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 06:10 PM
Something like that yeah.
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 06:12 PM
@Clone

Alright, Thanks!
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 07:22 PM
@Clone

How would I get the name of the last player. I can't see a way how I would do that.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
12 Apr 2015 07:23 PM
local alivePlayers = players:GetAlive()
local lastPlayer = alivePlayers[1]

print(lastPlayer.Name)
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 09:13 PM
@Clone

ok so i combined a few lines

i was wondering if this would work

if lastPlayer then
script.Parent.winner.Value = lastPlayer.Name
game.Workspace.SkipMap.Value = true
wait(1)
end
end

but when i run it in a actual server with a friend, it plays for a few seconds and then the round ends.

the skipmap bool is used to end the round when it's set to true
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 09:50 PM
It's like if it only scans one player and ends the round
Report Abuse
TehGabeNewell is not online. TehGabeNewell
Joined: 07 Feb 2013
Total Posts: 3165
12 Apr 2015 10:00 PM
bump

Does anyone know how to check fif theres one player in a team, I wanna do this with teams, it seems easier
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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