So I am having trouble making a barricade tool that when the model is placed (or the mouse is clicked) will place my block model. I am needing some help on adding a peice of script that will delete the tool from my backpack/inventory (im using the standard roblox backpack).
Here is my script so far:
bin = script.Parent function onButton1Down(mouse) local model = bin.model:clone() model.Parent = game.Workspace model:MakeJoints() model:MoveTo(mouse.hit.p) end function onSelected(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end if enabled then player.Backpack.tool:Destroy() end bin.Selected:connect(onSelected)
As incapaz mentioned, HopperBins are deprecated, so you should be using tools if you aren't already. The Activated event will specifically listen for clicks while a tool is equipped.
local tool = script.Parent function onActivated() --Do stuff tool:Destroy() end tool.Activated(onActivated)
Add this to the function at line 3:
mouse.Button1Down:Connect(function() player.Backpack.tool:Destroy() end)