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)
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?
player = game.Players.LocalPlayer --This creates a variable for the player
clone.Parent = player.Backpack -- setting "clone"'s parent to player.Backpack
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)
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.