How to clone the Roblox Battle Royale guns into the StarterPack from ReplicatedStorage?

Good Morning (Good Afternoon to some)! I have been working on a shooter for a while now and I was wondering if there was anyway to clone the Roblox Battle Royale guns from ReplicatedStorage to the StarterPack on a GUI button click.

I do understand that LocalScripts are unable to clone regular scrips because of security reasons. I have set up a Client-to-Server RemoteEvent; but I do not know what I should write in the ServerScript (Which is receiving the RemoteEvent from the LocalScript). The LocalScript is inside of a TextButton and the ServerScript is inside of ServerScriptService. My RemoteEvent is called “AK47Inv” which is also in ReplicatedStorage.

Thx guys!

Code from ServerScript:

local AK47Clone = game.ReplicatedStorage.AK47
local player = game.Players.LocalPlayer

game.ReplicatedStorage.AK47Inv.OnServerEvent:Connect(function(player)
    print("RemoteEvent has been Recieved!")
    AK47Clone:Clone().Parent = player.Backpack
    print("Weapon has been cloned and transferred!")
end)

Hey! Good afternoon/morning for you aswel!

Could you tell me if the tools/guns are a in a model or if they’re in a tool, like a real tool thing.

local player = game.Players.LocalPlayer

You can’t do this in a ServerScript, you will need to do this in a local script.
Other than that the script seems fine.

Hello @Mil_dev!

Yes the tools are an actual tool

Thank you for letting me know, @Minideliciouspant3!

So because of this, how would I put the tool into the backpack from the ServerScript? Do I need to do a Server-to-Client RemoteEvent, or do a Client-Server-Client RemoteFunction?

Or am I able to replace

game.Players.LocalPlayer

With:

game.Players:FindFirstChild()

Hello, I suggest you putting the tools in ServerStorage.

player = game.Players.LocalPlayer --This creates a variable for the player
clone.Parent = player.Backpack -- setting "clone"'s parent to player.Backpack

Another way would be.

local button = script.Parent.Button

local tool = "the path of your tool"

— local tool would be, game.ServerStorage, or game.replicatedstorage

-- Clicks on button with left mouse click

-- player behind function is the player who clicks on it

Button.MouseButton1Down:Connect(function(player)

    -- player who clicked backpack

    local location = player.Backpack

    -- make on other value and say that is the clone`

    local copy = Ak47Clonr:Clone()

    -- Value.Parent is the place where is should copy or clone to the local place I made

    copy.Parent = location

end)
1 Like

Thanks @Mil_dev :smile: 30char

You’re welcome, sorry I was testing something in a game. My excuses for the late response.

no problem! I was actually doing the same too. The same game I am talking about got the glitch where every part in it would be duplicated lol. I was just transferring everything to a new game.

Is it fixed or do you need help with it if yes message me the link to the post.