Hi, what I'm trying to do here is clone a weapon called "M16" to a players backpack. To do this, I try to cilck a Part and then it will clone a Weapon to a players backpack.
gunmodel = script.Parent players = game.Players.LocalPlayer function onClicked() for i = 1, #players do if gunmodel ~= nil then gun = game.Lighting.Weapons.M16:clone() gun.Parent = players.Backpack wait(.1) script.Parent:Destroy() end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Gun = game.Lighting.Weapons:FindFirstChild("M16") -- You first need to locate what you want to clone outside of the function. function onClicked(player) ClonedGun = Gun:clone() -- clone what you want and give it another name. ClonedGun.Parent = player.Backpack -- put what you cloned inside the backpack of the player wait(.1) script.Parent:Destroy() -- delete this if you want anyone who clicks on the brick to get the gun. end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)