IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 09:27 AM |
The !load vehicles - works on cloning the vehicle into the workspace, but the vehicle breaks apart?
and also the !clear vehicles, doesn't work. Any help? Here is the code:
local admins = {"iceorb"} local keyMessage = "!load vehicles" local keyMessage2 = "!clear vehicles"
function onChatted( Chat, Player ) if Chat:lower( ) == keyMessage then game.Lighting.Aspec:Clone().Parent = game.Workspace wait(1) game.Lighting.Crawler:Clone().Parent = game.Workspace else if Chat:lower( ) == keyMessage2 then for i, v in pairs(Workspace) do if v.Name == "Crawler" or v.Name == "Aspec" then v:Destroy() end end end end end
function onPlayerEntered(newPlayer) repeat wait() until newPlayer newPlayer.Chatted:connect(function(msg) for i = 1, #admins do if newPlayer.Name:lower() == admins[i] then onChatted(msg, newPlayer) end end end) end game.Players.PlayerAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 09:31 AM |
Use :MakeJoints() to ensure the welds and joints don't fall apart when it changes from Lighting to Workspace.
local p = Item:Clone() p.Parent = Workspace p:MakeJoints()
That should work.
Soup's on, everybody! ~LuaLearners Writer~ |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 09:33 AM |
Also, try putting
for i, v in pairs(Workspace:GetChildren())
That was my mistake.
Soup's on, everybody! ~LuaLearners Writer~
|
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 09:34 AM |
| For the :MakeJoints() - where would I put that? |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 09:37 AM |
Where I put in in the example
local findModel = model:Clone() findModel.Parent = game.Workspace findModel:MakeJoints()
Right after changing it's parent, not before.
Soup's on, everybody! ~LuaLearners Writer~ |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 09:39 AM |
| Yeah I think I've sorted it! I'll test it out! |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 09:43 AM |
Does it work?
Soup's on, everybody! ~LuaLearners Writer~ |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 10:30 AM |
| Haven't tested yet, but I'll see momentarally! |
|
|
| Report Abuse |
|
|
Arkose
|
  |
| Joined: 26 May 2013 |
| Total Posts: 745 |
|
|
| 28 May 2013 11:53 AM |
You are trying to loop through the workspace, so you need to use :GetChildren() in this line: You also had an extra end.
Your code: for i, v in pairs(Workspace) do My code: for i, v in pairs(Workspace:GetChildren()) do
local admins = {"iceorb"} local keyMessage = "!load vehicles" local keyMessage2 = "!clear vehicles"
function onChatted( Chat, Player ) if Chat:lower( ) == keyMessage then a = game.Lighting.Aspec:Clone() a.Parent = game.Workspace a:MakeJoints() wait(1) b = game.Lighting.Crawler:Clone() b.Parent = game.Workspace b:MakeJoints() else if Chat:lower( ) == keyMessage2 then for i, v in pairs(Workspace:GetChildren()) do if v.Name == "Crawler" or v.Name == "Aspec" then v:Destroy() end end end end
function onPlayerEntered(newPlayer) repeat wait() until newPlayer newPlayer.Chatted:connect(function(msg) for i = 1, #admins do if newPlayer.Name:lower() == admins[i] then onChatted(msg, newPlayer) end end end) end game.Players.PlayerAdded:connect(onPlayerEntered)
Need more help? Feel free to PM me :) |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 01:01 PM |
^^
I already said he needed to add :GetChildren(), That was my mistake.
Soup's on, everybody! ~LuaLearners Writer~ |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 01:09 PM |
Thanks for your help, also
if I want it to clone the vehicles into workspace how would I do that? Like especially if there is more than 1 vehicle. will the local p = vehicle thing clone all of them? |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 01:21 PM |
Any help please? It only gets one of the vehicles from lighting, and I need it to clone both but they have the same name. |
|
|
| Report Abuse |
|
|
Arkose
|
  |
| Joined: 26 May 2013 |
| Total Posts: 745 |
|
|
| 28 May 2013 01:23 PM |
Change the name?
Need more help? Feel free to PM me :) |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 28 May 2013 01:26 PM |
| Yeah, I've just done that; just thought there was an easier way. |
|
|
| Report Abuse |
|
|
|
| 28 May 2013 02:18 PM |
Use another for loop, but that's a massive waste of time. Just rename.
Soup's on, everybody! ~LuaLearners Writer~ |
|
|
| Report Abuse |
|
|