Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make cloned tools work in ReplicatedStorage?

Asked by 3 years ago

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!

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? SpeedySixTen 50 — 3y
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. ColdFoxy07 76 — 3y
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. jundell 106 — 3y
0
And what do you mean by “it breaks”? jundell 106 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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.

Ad

Answer this question