Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Weapon cloning isn't working correctly, Is there something wrong?

I have a shop system in place and the when the player buys a weapon it goes into a folder in StarterGear called BoughtContent and then when the player equips that tool it goes into EquippedContent. Now when a round starts in my game I want the EquippedContent tool to Clone into the Players Backpack.But when I'm trying to Clone a tool while testing online the tool is cloning to the players backpack without the scripts that work the tool.

This is the where the weapon is supposed to be cloned:

wep = p[i]:WaitForChild('StarterGear').PlayerStuff.EquippedContent:GetChildren()
for ii = 1,#wep do
wep[ii]:Clone().Parent = p[i]:WaitForChild("Backpack")
end

I have a folder in StarterGear that holds the stuff the player buys and then when a player equips a tool it clones into the backpack but only the handle and animation clones and the scripts don't.

1 answer

I think I see the problem, you don't have a variable for the cloned object and you don't have the parent assigned for the cloned object:

wep = p[i]:WaitForChild('StarterGear').PlayerStuff.EquippedContent:GetChildren()
wep2 = wep:Clone()
wep2.Parent = p[i]:waitForChild("Backpack")

Maybe that will work? I cant tell if the i's are supposed to replace numbers or what those mean but I hope this helps a bit.

This discussion is preserved as it was. New answers, comments, and votes are closed.