Tool's scripts won't work when cloned!

Hello!

So I wanted to make a button that once clicked, clones a Tool and places it in the player’s Backpack.

However, the issue is, when the Tool is cloned, scripts no longer work that are in the Tool!

Here is the script:


--// This is a LocalScript.
local Items = game.Workspace.Items
local Cookie = Items.Cookie
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local CookieClone = Cookie:Clone()
	CookieClone.Parent = player.Backpack
end)
1 Like

Does the cookie in the workspace have a script in it?

1 Like

If you clone a tool on the client-side and the script controlling the tool is a server-script, it won’t work because it wouldn’t know it got cloned in the first place.

The tool’s location wouldn’t change on the server-side.

4 Likes

Woah! I didn’t know that! Thanks for the help! :smiley:

@Xacima But, how will I clone it to the player’s backpack in a server-side script?

What do you mean? fire an event to the server when the player should equip it, and place it in their Backpack from a server script.

I mean when the player clicks a ImageButton the Tool will be cloned and parented to the player’s Backpack.

Fire an event to the server, and then clone it on the server and parent it to the backpack there.

And what arguments should I use?

Pass the tool name on the client, and on the server the player is automatically the first argument, and then search for the tool where you keep the tools with FindFirstChild, if it exists then clone it to the player’s backpack

1 Like

Thank you! Hopefully you will have a nice day! :smiley:

oooohhhhh thank u very math!!! u saved my day!

3 Likes