Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cloning an item to a player's inventory?

Asked by 5 years ago

I've been trying to use a script to clone an item to a player's inventory on a mouse click, but none of my attempts have work. Nothing happens, and there are no errors.

clicker = Instance.new("ClickDetector")
a280c = game.Workspace.weapons.A280C

clicker.MouseClick:Connect(function(playerWhoClicked)
    local player = playerWhoClicked
    local a_clone = a280c:Clone()
    a_clone.Parent = player.Character
    print("Cloning complete.")
end)

Does anyone know what's wrong with my code?

0
if you are cloning it into their inventory, clone it into their backpack theking48989987 2147 — 5y
0
The ClickDetector doesn’t seem to be parented to anything. If you’re trying to clone your item when a player clicks on an object, then parent the ClickDetector to that object. User#20279 0 — 5y
0
It has to go into the players backpack barrettr500 53 — 5y

1 answer

Log in to vote
0
Answered by
blockmask 374 Moderation Voter
5 years ago
Edited by User#24403 5 years ago

First of all, the clickdetector is made, but has no properties such as it's Parent, second of all, don't clone a tool into the character, clone it to the player`s backpack. If you want the player to equip it, then use humanoid:EquipTool(tool)

local weapon = workspace.Weapon

local clickdetector = Instance.new("ClickDetector")
clickdetector.Parent = workspace.Part

function Clicked(player)
    weapon:Clone().Parent = player:WaitForChild("Backpack")
    print("cloning complete")
end

clickdetector.MouseClick:Connect(Clicked)
0
ignore the capital "p" in "Print" blockmask 374 — 5y
0
You can edit your answer by clicking on the Edit button below this comment section. xPolarium 1388 — 5y
Ad

Answer this question