|
| 10 Jan 2015 08:03 AM |
I have created a table called parts, and I am trying to get all of those parts UnAnchored.
Hi = true local a = script.Parent function OC() if Hi == true then Hi = false Parts.Anchored = false wait(5) local new = a:clone() new.Parent = script.Parent new:MakeJoints() Parts.Anchored = true Hi = true end end game.Workspace.Button2.Part1.ClickDetector.MouseClick:connect(OC)
problem is, nothing is happening when it's clicked! |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 10 Jan 2015 08:04 AM |
| idk am i blind or what but i cant see a table anywhere |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 08:06 AM |
| It was 30 lines long, I didn't want it 2 long. just assume it has parts 1-25 |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 10 Jan 2015 08:09 AM |
Hi = true local a = script.Parent function OC() if Hi == true then Hi = false for _,part in pairs(Parts) do part.Anchored = false -- if there is path to part then do this, else do workspace[part].Anchored = false -- or whatever parent of it is end wait(5) local new = a:clone() new.Parent = script.Parent new:MakeJoints() Parts.Anchored = true Hi = true end end game.Workspace.Button2.Part1.ClickDetector.MouseClick:connect(OC) |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 08:18 AM |
To erase stuff out of a table try this metatable.
local metatable01 = { _call = function(self) for i=1, #self do self[i]:Remove() table.remove(i) end end }
local table2 = {This is where your parts are} setmetatable(table2, metatable01)
To clear your table do this: table2() |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 09:49 AM |
I'm afraid it didn't work, but I'm getting an error,
11 is not a valid member of Model
it has been 18, 16, 5, any random part, but I guess I should give you the table...
local Parts = { [game.Workspace.HitMe.Part1] = 1, [game.Workspace.HitMe.Part2] = 2, [game.Workspace.HitMe.Part3] = 3, [game.Workspace.HitMe.Part4] = 4, [game.Workspace.HitMe.Part5] = 5, [game.Workspace.HitMe.Part6] = 6, [game.Workspace.HitMe.Part7] = 7, [game.Workspace.HitMe.Part8] = 8, [game.Workspace.HitMe.Part9] = 9, [game.Workspace.HitMe.Part10] = 10, [game.Workspace.HitMe.Part11] = 11, [game.Workspace.HitMe.Part12] = 12, [game.Workspace.HitMe.Part13] = 13, [game.Workspace.HitMe.Part14] = 14, [game.Workspace.HitMe.Part15] = 15, [game.Workspace.HitMe.Part16] = 16, [game.Workspace.HitMe.Part17] = 17, [game.Workspace.HitMe.Part18] = 18, [game.Workspace.HitMe.Part19] = 19, [game.Workspace.HitMe.Part20] = 20, [game.Workspace.HitMe.Part21] = 21, [game.Workspace.HitMe.Part22] = 22, [game.Workspace.HitMe.Part23] = 23, [game.Workspace.HitMe.Part24] = 24, [game.Workspace.HitMe.Ball] = 25 } |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 10 Jan 2015 09:54 AM |
well it should be
[1] = workspace.HitMe.Part1, [2] = workspace.HitMe.Part2, etc
but just changing
for _,part in pairs(Parts) do
to
for part,_ in pairs(Parts) do
might work
|
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 09:59 AM |
function OC() for i,v in pairs(workspace.HitMe:GetChildren()) do v.Anchored = false end end
game.Workspace.Button2.Part1.ClickDetector.MouseClick:connect(OC) |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 10:05 AM |
I have for _,part in pairs(Parts) do workspace.HitMe[part].Anchored = false end --(cause that's where it's located) and I get this error
Workspace.HitMe.Script:34: bad argument #2 to '?' (string expected, got userdata) |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2015 10:06 AM |
You passed in an object as an index.
for _,part in pairs(Parts) do part.Anchored = false end |
|
|
| Report Abuse |
|
|
| |
|