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

how do i make it so that when i click on something i get that item i clicked?

Asked by
Alex08l 10
2 years ago

i want to make it so that when i click on a candle on a table i get that candle

0
Use a click detector and connect mouse click event, then clone a copy of the tool to player's backpack SuperPuiu 497 — 2y
0
what is a mouse click event? Alex08l 10 — 2y
0
@Alex08l click mouse event is really just something that happens when you click your mouse (someone correct me if i'm wrong) SmockyBocky 5 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Make a "Click Detector" and put it under the candle. Then put this Script under the candle:

local clickDetector = script.Parent:FindFirstChild("ClickDetector")
local Clone = game.Workspace.Candle:Clone() 
local LocalPlayer = game.Players.LocalPlayer

function onMouseClick()
    Clone.Parent = game.Players.LocalPlayer.Backpack
end

clickDetector.MouseClick:connect(onMouseClick)

(this script will only work if the candle is a Tool, if it's not a tool I don't think it's possible to put it in the player's inventory.)

0
what if its a group? Alex08l 10 — 2y
Ad

Answer this question