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

Cloning breaks my tool, any help? [Elaboration in desc]

I have my gun in ReplicatedStorage and a simple script in a GUI which when you press, the gun gets cloned and transferred to your backpack. The script works but when I equip the gun it doesn't work at all but if I directly put the gun in the StarterPack and play, it works perfectly fine. I have no idea how to fix this and have searched online and found nothing.

Here is the GUI Script:

local tool = game.ReplicatedStorage.Musket
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	tool:Clone()
	tool:Clone().Parent = player.Backpack
end)

1 answer

Try making a Remote Event and making the script fire it.

	local tool = game.ReplicatedStorage.Musket
	local player = game.Players.LocalPlayer
        local event  = game.ReplicatedStorage.Clone --Name the event that
	 
	script.Parent.MouseButton1Click:Connect(function()
	    event:FireServer()
	end)

My bad. Actually just make a server script in serverscriptservice and use the following code

game.ReplicatedStorage.Clone.OnClientEvent:Connect(Function(player)
local b = game.ReplicatedStorage.Musket:Clone()
b.Name = "Musket"
b.Parent = player.Backpack
end)

4 comments

0

So I added a RemoteEvent called 'Clone' in ReplicatedStorage, created the server script in serverscriptservice and used the code aaand it didn't appear in the backpack. Shouldn't it fire once I press on the GUI?

0

The GUI is located in StarterGui > Class > Frame > Infantry [ButtonLabel]

0

What script are you using to fire the event?

0

Wait! Mb, I forgot to add the end) try it again but paste the new scripts where they need to go.

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