Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Inserting Tool into BackPack via ClickDetector?

How to make a script where the player who clicked on the tool will make the tool to go to his backpack?

function OnClick(Clicker)
print("The player who clicked is named: " .. Clicker.Name) script.Parent:Clone().Parent = game.Players.LocalPlayer.BackPack script.Parent:Destroy()

end script.Parent.ClickDetector.MouseClick:connect(OnClick)

1 answer

Add a ClickDetector into the handle of the tool along with this script.

script.Parent.Parent.ClickDetector.MouseClick:connect(function()
	for _, v in pairs(game.Players:GetPlayers()) do
	print("The player who clicked is named: " .. v.Name)
	script.Parent.Parent:Clone().Parent = v.Backpack
	script.Parent.Parent:Destroy()
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.