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

How do I detect if an object is clicked without a click detector?

I don't have much code set up, but to make it easier I want to detect if an object is clicked without any ClickDetectors.

2 comments

0

Why do you not want a ClickDetector? It's easier to use them

0

Yes, but when there's a lot of parts in the game it might be easier to just use a script.

1 answer

✓ Accepted answer

There is a way to do this on the client side.

local player = game:GetService(“Players”).LocalPlayer
local mouse = player:GetMouse()

local clickableObject = workspace.Part

mouse.Button1Down:Connect(function()
      if mouse.Target ~= nil and mouse.Target == clickableObject then
            — Object has been clicked. 
      end
end)

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