I have done something similar using ServerStorage in an initialization script that is called when a player is added. I used server storage for security reasons.
-- Required Game Services and Facilities
local playerService = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
playerService.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local backpack = player.WaitForChild("Backpack", 10)
for _, weapon in pairs(serverStorage.Weapons:GetChildren()) do
local tool = weapon:Clone()
tool.Parent = backpack
end
end)
end)
In ServerStorage, I have a folder called âWeaponsâ where everything in that folder is cloned into the playerâs backpack. You can use ReplicatedStorage by just changing ServerStorage to ReplicatedStorage and it should work. However, I would recommend using ServerStorage for security reasons, and not a local script to clone tools to the playerâs backpack. An exploiter can take advantage of this. But for input type detection, just do a FireServer event from the client to pass the information along to the server. Besides, Iâm not sure if you can clone an item to a playerâs backpack on the client side. Being able to do so would be a major security issue because then a player can clone any tool into your game. Now whether it works or not is a different issue.