ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 12 Aug 2012 10:35 PM |
Ok so I made my new "minion" script, a lot like the camball, and I was trying to make a respawn command so when I died, I could create my model again and control the new one. To do this, I thought I could just create the model in Lighitng, and then clone it to Workspace and then start controlling it. Unfortunately, this didn't work. I'm pretty sure it should, but here's a portion of my script.
function Weld(parta, partb) local weld = Instance.new("Weld") weld.Part0 = parta weld.Part1 = partb weld.C0 = CFrame.new() weld.C1 = partb.CFrame:inverse() * parta.CFrame return weld; end
Weld(head, torso).Parent = Workspace Weld(larm, torso).Parent = Workspace Weld(rarm, torso).Parent = Workspace Weld(lleg, torso).Parent = Workspace Weld(rleg, torso).Parent = Workspace
char = game.Lighting.Jesus:clone().Parent = Workspace
charparts = char:GetChildren() for i = 1, #charparts do if charparts[i].className == "Part" then charparts[i].Anchored = false end end
---------- Body Switch ----------
local pl = game.Players.LocalPlayer local ch = game.Players.LocalPlayer.Character game.Players.LocalPlayer.Character = char ch.Parent = nil pl.Parent = nil
Obviously it's something wrong with my clone() function. Atleast I think it is O__O, Help would be greatly appreciated. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 10:48 PM |
You problem is
char = game.Lighting.Jesus:clone().Parent = Workspace
You must have them as 2 different statements, the fix:
char = game.Lighting.Jesus:clone() char.Parent = Workspace. |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 12 Aug 2012 10:55 PM |
| Hm. I always thought you could do that :/ Well I sure was wrong... |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 12 Aug 2012 10:58 PM |
| Nevermind I was right I can do that. It didn't help changing it. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 11:00 PM |
| char:MakeJoints() Do that also btw. Output? |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 11:01 PM |
| Your basically deleting the player with pl.Parent = nil... |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 11:01 PM |
cwat is right, the reason why it didn't error was because it's in a localscript
try adding a wait(1) on the top of the script (while fixing according to cwats suggestion) |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 12 Aug 2012 11:07 PM |
@cwat
I know I'm deleting my character, but it still works and controls the model. It used to work before I tried storing it in Lighting and then cloning it to Workspace.
@bro
That didn't work. |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 12 Aug 2012 11:29 PM |
| Ok well I fixed that error, but I have a new problem. How do I get the individual names of the parts inside of a model? I need this so that I can weld together the cloned parts inside of the cloned model. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2012 12:00 PM |
@shoe
local lastpart = nil
for _,v in pairs(char:getChildren()) do if lastpart == nil then lastpart = v else weld(lastpart, v) end end |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Aug 2012 01:58 PM |
The welding works, but after it welds, nothing else runs. So my figure is stuck up in the sky.
function Weld(parta, partb) local weld = Instance.new("Weld") weld.Part0 = parta weld.Part1 = partb weld.C0 = CFrame.new() weld.C1 = partb.CFrame:inverse() * parta.CFrame return weld; end
char = model:clone().Parent = Workspace char:MakeJoints()
local lastpart = nil
for _,v in pairs(char:getChildren()) do if lastpart == nil then lastpart = v else Weld(lastpart, v).Parent = Workspace end end
for _, charp in pairs(char:GetChildren()) do if charp.className == "Part" then charp.Anchored = false end end
---------- Body Switch ----------
local pl = game.Players.LocalPlayer local ch = game.Players.LocalPlayer.Character game.Players.LocalPlayer.Character = char ch.Parent = nil pl.Parent = nil |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Aug 2012 02:20 PM |
@cwat
Could you please help? Lol hopefully you see this... Or somebody else. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2012 02:27 PM |
| Where is the script placed? Try putting it in either Backpack or PlayerGui |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Aug 2012 02:28 PM |
| It's used in script builder O__O |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
| |
|
|
| 13 Aug 2012 03:41 PM |
I know why! When you try to clone it, you put the c lowercase: clone() You need to put the c as a capital: Clone() |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Aug 2012 03:54 PM |
@Spongo
Capital or not, it doesn't matter. In case I was wrong, I tested it, and it still did the same thing.
Ok so I put it in a regular script so i could get some output and it told me that I can't use model:Clone().Parent = Workspace. It has to be on two seperate lines like cwat said. Sorry cwat. And then I got some strange output.
13:49:52 - bad cast 13:49:52 - Script "Workspace.Script", Line 140 - global Weld 13:49:52 - Script "Workspace.Script", Line 156 13:49:52 - stack end
Here are the lines:
---------- Welding ----------
function Weld(parta, partb) local weld = Instance.new("Weld") weld.Part0 = parta weld.Part1 = partb -- Line 140 weld.C0 = CFrame.new() weld.C1 = partb.CFrame:inverse() * parta.CFrame return weld; end
char = model:Clone() char.Parent = Workspace char:MakeJoints()
local lastpart = nil
for _,v in pairs(char:getChildren()) do if lastpart == nil then lastpart = v else Weld(lastpart, v).Parent = Workspace -- Line 156 end end
for _, charp in pairs(char:GetChildren()) do if charp.className == "Part" then charp.Anchored = false end end |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
| |
|
usama8800
|
  |
| Joined: 29 Dec 2009 |
| Total Posts: 225 |
|
|
| 13 Aug 2012 04:25 PM |
for _,v in pairs(char:getChildren()) do if lastpart == nil then lastpart = v else if lastpart:IsA("Part") then Weld(lastpart, v).Parent = Workspace -- Line 156 end end end |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 13 Aug 2012 04:35 PM |
Ok I fixed it myself somehow
lastpart = nil for _, v in pairs(char:GetChildren()) do if lastpart == nil then lastpart = v Weld(lastpart, v).Parent = Workspace end end
But It only creates 1 weld, and it welds two of the same parts together. When I ran the script, my model just fell apart and broke, so I check the weld in workspace. It said Part0 is Head and Part1 is Head. |
|
|
| Report Abuse |
|
|