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

How to detect a player's click without a tool? [SOLVED]

I'm trying to destroy a part when I click it. What I tried to do is below:

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
	mouse.Target:Destroy()
	warn("working")
end)

I'm using a local script but the warn doesn't work and neither does the destroying of the part. I also used a remote event to see if that would help, it accomplished nothing. I'd appreciate any help to this problem.

2 comments

0

What do you need to work with a mouse click

0

if mouse.Target then mouse.Target:Destroy() end

1 answer

using clickdetector. it works so well that it will work with a part, or a model. basically you do this, put a script file right under the object you want to destroy,

local part = script.Parent
local cd = Instance.new("ClickDetector", cd)
cd.MouseClick:Connect(function(player)
	-- do whatever you want to destroy the part.
end)

1 comment

0

Thanks for the answer, but I was trying to do this with just the players mouse input. It turns out my problem was just a bug in that particular local script.

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