|
| 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 |
|
|
|
| 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 |
|
|
|
| 12 Apr 2015 05:07 PM |
@Clone
I tested it and it gave me a error
"attempt to compare number with table" |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2015 05:08 PM |
Oh.
Change it to #players:GetAlive() > 1 sorry lol.
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 12 Apr 2015 05:15 PM |
Heres a handy function:
function isPlaySolo() return game.JobId == "" end |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 12 Apr 2015 06:03 PM |
@Clone
The print is weird, it says stuff like
"table: 178D4A08 players left" |
|
|
| Report Abuse |
|
|
|
| 12 Apr 2015 06:03 PM |
| Once again, change it to #players:GetAlive() |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
| |
|
|
| 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 |
|
|
|
| 12 Apr 2015 07:23 PM |
local alivePlayers = players:GetAlive() local lastPlayer = alivePlayers[1]
print(lastPlayer.Name) |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 12 Apr 2015 09:50 PM |
| It's like if it only scans one player and ends the round |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|