Tool:Clone() Doesn't seem to work

Today i decided to make a Gun Dealer system using a GUI, it works but somehow after clicking it once it doesn’t seem to give the tool again. I moved it to ReplicatedStorage and change the script from ServerStorage to ReplicatedStorage, and the reason why it doesn’t want to give the tool again is because it was moved into the Player’s backpack without cloning. Keep in mind i used “:Clone()” and still have that issue

Script

local M4A4_REM = game.ReplicatedStorage.Remotes.BuyM4A4

--//Storage
local Storage = game.ReplicatedStorage.ToolFolder

--//Tools
local M4A4 = Storage.M4A4

M4A4_REM.OnServerEvent:Connect(function(Player)
	M4A4:Clone()
	M4A4.Parent = Player.Backpack
end)

if anyone has a solution to this, you may reply.

It’s because M4A4:Clone() is not a variable so the tool just cloned without anything new being assigned to it. Try this:

local M4A4Clone = M4A4:Clone()
M4A4Clone.Parent = Player.Backpack

EDIT: I should clarify that it just duplicated your first M4A4 tool and since you can’t refer back to your cloned object, you just changed the parent of your original M4A4 which can no longer be found in the ToolFolder.

1 Like

try this code

Code
local M4A4_REM = game.ReplicatedStorage.Remotes.BuyM4A4

--//Storage
local Storage = game.ReplicatedStorage.ToolFolder

--//Tools
local M4A4 = Storage.M4A4

M4A4_REM.OnServerEvent:Connect(function(Player)
	M4A4:Clone().Parent = Player.Backpack
end)
1 Like

Thank you so much, it works pretty well!

1 Like

I’ve already found a solution for it, thanks to ConfidentLetter. But thank you for replying!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.