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: Table Help

Previous Thread :: Next Thread 
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
28 Sep 2011 03:37 PM
local TotalPlayers = {}
local PlayersLeft = {}
wait(1)
for a,v in pairs(game.Players:GetPlayers()) do
table.insert(TotalPlayers,v)
table.insert(PlayersLeft,v)
wait(4)
end end
repeat
for i = #PlayersLeft,0 do
if v.Humanoid.Health == 0 then
table.remove(PlayersLeft,a)
end
ChangeGuiText(game.Players,"Players Remaining"..#PlayersLeft.. "/" ..#TotalPlayers)
wait(1)
end
until #PlayersLeft == 0
ChangeGuiText("GAME OVER")
wait(444)
end

the output is
Workspace.Main:46: attempt to get length of global 'PlayersLeft' (a nil value)
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
28 Sep 2011 03:49 PM
local TotalPlayers = {}
local PlayersLeft = {}
wait(1)
for a,v in pairs(game.Players:GetPlayers()) do
table.insert(TotalPlayers,v)
table.insert(PlayersLeft,v)
wait(4)
end end -- You have two ends here, meaning that the local variables above go out of scope
repeat
for i = #PlayersLeft,0 do -- this doesn't run because #PlayersLeft > 0, and it can't add 1 to a positive number to get 0
if v.Humanoid.Health == 0 then -- v isn't defined. Try for a, v in pairs(PlayersLeft) do instead
table.remove(PlayersLeft,a) -- see above
end
ChangeGuiText(game.Players,"Players Remaining"..#PlayersLeft.. "/" ..#TotalPlayers)
wait(1)
end
until #PlayersLeft == 0
ChangeGuiText("GAME OVER")
wait(444)
end


I didn't know exactly how to fix it because this isn't the full script so I don't know the effects of changing stuff in it. My only thought is to make PlayersLeft and TotalPlayers global variables (take away the local part).
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
28 Sep 2011 03:50 PM
Texts = {""}
MapAmount = 1




function ChangeGuiText(tab,string,func)
if type(tab) ~= "table" then tab = tab:GetChildren() end
for a,v in pairs(tab) do
if v:findFirstChild("PlayerGui") then
v.PlayerGui.Gui.Frame.Text.Text = string
pcall(function() func(v) end)
end end end



local gamenum = 0
while wait(.1) do
if game.Players.NumPlayers > 0 then
gamenum = gamenum + 1
local fakenum = gamenum
local m = math.random(1,MapAmount)
script.Time.Value = 0













local TotalPlayers = {}
local PlayersLeft = {}
wait(1)
for a,v in pairs(game.Players:GetPlayers()) do
table.insert(TotalPlayers,v)
table.insert(PlayersLeft,v)
wait(4)
end end
repeat
for i = #PlayersLeft,0 do
if v.Humanoid.Health == 0 then
table.remove(PlayersLeft,a)
end
ChangeGuiText(game.Players,"Players Remaining"..#PlayersLeft.. "/" ..#TotalPlayers)
wait(1)
end
until #PlayersLeft == 0
ChangeGuiText("GAME OVER")
wait(444)
end
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
28 Sep 2011 04:07 PM
What the script u gave me, i freeze when it starts
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