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

How do I make cloned tools work in ReplicatedStorage?

Hey there! I'm making a game where you can use knives. But there is one problem, when I clone the specified knife out of ReplicatedStorage, it breaks. The tool gets cloned whenever a TextButton is pressed. I'm not necessarily asking for a script, an explanation will do fine.

Any help is greatly appreciated!

4 comments

0

Could we get more context? What type of script are you using? Where is the script stored? What code are you using to retrieve the Tool?

0

As of right now, I don't have any scripts. I tried using a server script to clone the tool, but it did not work. I am just asking for an explanation on how I would do this.

0

“The tool gets cloned whenever a TextButton is pressed” That sounds like you’d be using a LocalScript to do that, just make sure it isn’t one.

0

And what do you mean by “it breaks”?

1 answer

✓ Accepted answer

The tool gets cloned whenever a TextButton is pressed. Sorry, I thought this meant that you already had a script. Since you don't already have a script, here is one that I tested using real quick:

function onClicked()
	local player = script.Parent.Parent.Parent.Parent
	local backpack = player:WaitForChild("Backpack")
	local cloneTool = game.ReplicatedStorage.Tool:Clone()
	cloneTool.Parent = backpack
end

script.Parent.MouseButton1Click:Connect(onClicked)

I did see that you said that you tried using a server script before and it didn't work - this is probably because you tried adding the tool to the backpack immediately, but you have to wait for the backpack to load in first otherwise it will not work (this is why it's good practice to use :WaitForChild()). There's probably a more efficient way to get the player, but what I did is I just kept on adding .Parent until I reached it. Hope this solves your problem.

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