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: Removes Children on Cloning??

Previous Thread :: Next Thread 
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Jun 2013 10:25 PM
This is really strange... When I clone something, it removes the children of the object I cloned. I checked and made sure that Archivable was set to true for the thing I'm cloning (a Tool), and all of its children had Archivable set to true as well. When I clone the object, it clones the tool itself, but deletes (I'm guessing) its children (a Part and a LocalScript).
It works fine if I don't delete the Tool afterwards, but for some odd reason it doesn't if I do delete the Tool.
Anyways, here's the code:

local t = game.Lighting.Tank
local t2 = game.Lighting.Tank:Clone()
script.Parent.Touched:connect(function(hit)
script.Parent.ChildAdded:connect(function()
if hit then
if hit.Parent:FindFirstChild("Humanoid") then
character = hit.Parent
player = game.Players:GetPlayerFromCharacter(character)
t2.Parent = player.Backpack
end
end
end)
end)

script.Parent.TouchEnded:connect(function() -- This breaks the "Tank" Tool.
game.Debris:AddItem(t2,0)
end)

This Script is inside a VehicleSeat. If you're wondering about the ChildAdded Event, that's there so the Player has to be siting in order to receive the Tool. Is there a reason for it to be acting like this, or is this just some strange error??
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
11 Jun 2013 10:59 PM
Dear Zkiller11,
believe the children removal was because of a bug, when I do it, it doesn't remove the child, make sure you debug

Sincerely, Laughablehaha
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Jun 2013 11:06 PM
...

Um

Ignoring the oddity of that post, yea, I think it is a bug. I posted this thread searching for help. Can you provide that help please?
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Jun 2013 11:46 PM
Bump
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 12:39 AM
Bump.
Report Abuse
AxeOfMen is not online. AxeOfMen
Joined: 14 Dec 2011
Total Posts: 196
12 Jun 2013 01:09 AM
I've experienced this problem before when cloning an object. IIRC, the problem was because I was cloning a tool from within a LocalScript. That is to say, there was a local script that was performing the clone of the tool and from there I was putting it in the StarterGear. At that point the script inside the tool had vanished. The solution was to change the tool to contain a LocalScript instead of a script.

One other note is that it would work in Play Solo mode but not in Online Mode

If possible, try cloning from within a LocalScript instead of a Script. See if this clears up the issue for you.

Good luck!
Report Abuse
AxeOfMen is not online. AxeOfMen
Joined: 14 Dec 2011
Total Posts: 196
12 Jun 2013 01:12 AM
"I was cloning a tool from within a LocalScript."

I meant to say that I was cloning from within a Script, not a LocalScript. It's all rather confusing. The takeaway:

"Try cloning from within a LocalScript instead of a Script."

Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
12 Jun 2013 01:29 AM
Actually, there is one reason it won't work.
You are cloning the object, and only the object. You are not cloning the children.
To do what you want it to do:
tank = game.Workspace.Tank
tank:Clone()
--blah blah blahs
Report Abuse
shrekpasta is not online. shrekpasta
Joined: 30 Sep 2012
Total Posts: 11
12 Jun 2013 01:29 AM
hi
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
12 Jun 2013 01:31 AM
Actually, I'll just fix it:
local t = game.Lighting.Tank
local t2 = t:Clone()
script.Parent.Touched:connect(function(hit)
script.Parent.ChildAdded:connect(function()
if hit then
if hit.Parent:FindFirstChild("Humanoid") then
character = hit.Parent
player = game.Players:GetPlayerFromCharacter(character)
t2.Parent = player.Backpack
end
end
end)
end)

script.Parent.TouchEnded:connect(function() -- This breaks the "Tank" Tool.
game.Debris:AddItem(t2,0)
end)
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 01:38 AM
@Axe: I'd use a LocalScript, but because of the current situation, I can not. (The script is in a Vehicle Seat.)

@Sam: According to the Wiki, I don't have to Clone the Descendants:

"Returns a clone of the object and its children, unless its Archivable property is false. The clone will have the same properties as the original object and the same descendants (except those with an Archivable property set to false). The clone's Parent will be nil unless changed."

@Shrek: 'Sup
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
12 Jun 2013 01:43 AM
Try my solution before dismissing it.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 01:52 AM
I'm sorry, you ninja'd me. I tried your code; it didn't work.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 12:07 PM
Bump
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 12:24 PM
Bump.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 12:41 PM
Bump..
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 12:58 PM
Bump...
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 01:36 PM
Bump....
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 02:15 PM
Anyone out there? .-.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 02:57 PM
...
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Jun 2013 03:45 PM
So now I'm just cloning the original object and its Children.. Is this how I'm going to have to do this, or is there a fix for it??
Report Abuse
hman1198 is not online. hman1198
Joined: 30 Mar 2010
Total Posts: 494
18 Oct 2013 03:59 PM
Have you checked the children's "archivable" value? If it's set to false, I do not think you can clone them along with the parent.


"Idiocy is the worst disease in mankind. Be the cure."

-Hman1198
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