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

Tool in replicated storage not cloning?

Hello everyone!

To see if my script for cloning a tool to every player's backpack was working, I tested the cloning part in the Command Bar.

sword = game.ReplicatedStorage.Swords.BasicSword

sword:Clone()

It gave no errors in the output, but a clone of the tool did not show up in the swords folder. Can someone please tell me why it does not clone and how I can do it in a script with server storage?

Thanks in advance :)

2 answers

✓ Accepted answer

Like @D3VRO said, you have to parent the clone to a place. Clones aren't actual duplicates that are visible in explorer, they're cloned within the code and become visible once you set a parent for the clone.

Now how can you do it in ServerScriptService (Not ServerStorage, that's like ReplicatedStorage, but clients/exploiters can't see it, it's a safer spot to put the tools):

Well, if you're cloning the tool to all players once they join the game, you can go about it like this:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local sword = game.ReplicatedStorage.Swords:FindFirstChild("BasicSword"):Clone()
	sword.Parent = player.Backpack
	--[[ Or if you want it to instantly equip then you could do
		sword.Parent = player.Character ]]--	
end)

Tell me how things go for ya!

You didn't parent the tool to the players backpack. You'd have to do something like this:

sword = game.ReplicatedStorage.Swords.BasicSword:Clone()
sword.Parent = player.Backpack

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