fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 06:52 AM |
I'm bad at using for loops, so I am trying to practice using them, I don't know what is wrong with this.
local ingame = Workspace:GetChildren()
for i,v in pairs(ingame) do if ingame.Name~=Spawn then ingame:Delete() end end |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 06:53 AM |
>:Delete() isnt a real method
try this:
local ingame = game.Workspace:GetChildren()
for i,v in pairs(ingame) do if v.Name~= "Spawn" then v:Destroy() end end |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 06:54 AM |
Changed the code a little bit, I've tested and it just disconnects the event I've attached it to.
local kids = Workspace:GetChildren()
for i,v in pairs(kids) do if kids[i].Name~=Spawn then ingame[i]:Delete() end end |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 06:56 AM |
| Oh man, I fixed it and it sends the camera flying away from the spawn, but doesn't destroy anything. |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 26 Jul 2014 06:58 AM |
first off dont do :Delete() do :Destroy() also, for i,v in pairs(kids) do (kids) is the objects youre getting if you want to edit those objects you do something like v:Destroy()
and use this:
local kids = game.Workspace:GetChildren()
for i,v in pairs(kids) do if v.Name~=Spawn then v:Destroy() end end |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 07:00 AM |
So I changed it so it doesn't delete anything I don't want to... except, the player itself.
Should I use GetPlayers like this
for i,v in pairs(kids) do if kids[i].Name~=game:GetPlayers end |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 07:08 AM |
Sorry, I posted an older version of the script that had :Delete instead of :Destroy. Fail me.
How would I not delete the players, because they are all Children of Workspace? |
|
|
| Report Abuse |
|
|
fret13103
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 881 |
|
|
| 26 Jul 2014 07:28 AM |
Did it guys...
This is the code.
for i,c in pairs(players) do for i,v in pairs(kids) do if v.Name~="Spawn" and v.Name~="Camera" and v.Name~="Instance" and v.Name~="Terrain" and v.Name~="Pos" and v.Name~=c.Name then v:Destroy() end end |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 07:31 AM |
| What are you trying to do? |
|
|
| Report Abuse |
|
|