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

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

Asked by
sngnn 274 Moderation Voter
4 years ago

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.

0
Why do you not want a ClickDetector? It's easier to use them programmerHere 371 — 4y
0
Yes, but when there's a lot of parts in the game it might be easier to just use a script. sngnn 274 — 4y

1 answer

Log in to vote
0
Answered by
Alphexus 498 Moderation Voter
4 years ago

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)
Ad

Answer this question