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: Problem with table.remove()

Previous Thread :: Next Thread 
ArcticGenesis is not online. ArcticGenesis
Joined: 22 Apr 2013
Total Posts: 76
08 May 2013 10:57 PM
There acually is no producable error in this, it just doesnt work right :/
It teleports the judges but doesnt teleport the other players, I tried this on a server with 4 people, (Local server).

workspace = game.Workspace
lighting = game.Lighting
Players = game.Players
folder = script.Parent
maps = game.Lighting.Maps:GetChildren()
map_chosen = folder["Map_Chosen"]
gameRunning = folder["GameRunning"]
players = {}
NORMplayers = {}

--[[Functions]]--
function gatherPlayers()
local Player = Players:GetPlayers()
for i = 1, #Player do
table.insert(players,Player[i].Name)
end
end
--[[Judges]]-- Error probably below
function makeJudges()
gatherPlayers()
local Player = Players:GetPlayers()
for i = 1, #Player do
table.insert(NORMplayers, Player[i].Name)
table.remove(NORMplayers, jug)
end
end

function moveJudges()
for i = 1, #NORMplayers do
game.Players[NORMplayers[i]].Character:MoveTo(Vector3.new(-57, 1.8, 43))
end
end
---XX-----XX---Error Probably in up top

--[[Jug Functions]]
function makeJug()
gatherPlayers()
return players[math.random(#players)]
end

function moveJug()
jug = makeJug()
game.Players[jug].Character:MoveTo(Vector3.new(-21, 10, 99))
end
--XX------------XX--
--[[Main Program]]--
while true do
wait(1)
print("Creating jug, Creating Judges")
wait(2)
print("Moving Jug, Moving Judges")
wait(2)
moveJug()
wait(1)
moveJudges()
end

(ง'̀-'́)ง
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 May 2013 11:01 PM
"table.remove(NORMplayers, jug)"
What is jug?

Also, table.remove only works with the index.
table.remove(Table, 1) -- will work
table.remove(Table, "Hi") -- will not work
Report Abuse
ArcticGenesis is not online. ArcticGenesis
Joined: 22 Apr 2013
Total Posts: 76
08 May 2013 11:04 PM
I know what you mean, but what Im trying to do is remove player that is a jug,
it could be any number of the tables index.

(ง'̀-'́)ง
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 May 2013 11:16 PM
Okay, say this is the juggernauts:

Juggernauts = {"Player1"; "Player2"}

And say Player1 and Player 3 die.

--player died connection
for _, Juggernaut in next, Juggernauts do
if Juggernaut == Player.Name then
table.remove(Juggernauts, _)
end
end
--end player died connection
Report Abuse
ArcticGenesis is not online. ArcticGenesis
Joined: 22 Apr 2013
Total Posts: 76
08 May 2013 11:33 PM
Thank you, but that is not what Im trying to get at. Say I a variable that was "Jug"
and a table named "Players", and I wanted to remove the jug from the table so I could teleport the players, how would I do that?

(ง'̀-'́)ง
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
08 May 2013 11:40 PM
Variable = "This is a variable"

Table = {"I'm in a table", "This is a variable"}

for _, V in next, Table do
if (V == Variable) then
table.remove(Table, _)
end
end
Report Abuse
ArcticGenesis is not online. ArcticGenesis
Joined: 22 Apr 2013
Total Posts: 76
08 May 2013 11:54 PM
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