so basically make my click function not work if local script detects if mouse clicked on a click detector or hovering on a click detector (ill take either)
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if (UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)) then
--IF STATEMENT OF MOUSE ON CLICK DETECTOR HERE IDK WHAT TO PUT
--return end
print("Player Clicked !")
end
end)
You could create a function of the code that happens when the event is triggered and just call the function when the event is fired Example:
local function this()
--Code
end
workspace.Part.ClickDetector.MouseClick:Connect(function(player)
this()
end)
workspace.Part.ClickDetector.MouseHoverEnter:Connect(function(player)
this()
end)
I mean, you could check to see if the part hovering over is in a table, but this means you won’t need a ClickDetector:
local clickparts = {workspace.Part1, workspace.Part2}
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
if table.find(clickparts, mouse.Target) then
--do click code
end
end)
Not exactly what I was looking for but ur advice did give me an idea
local UserInputService = game:GetService("UserInputService")
local Player = game:GetService('Players').LocalPlayer
local Mouse = Player:GetMouse()
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if (UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)) then
local children = Mouse.Target:GetChildren()
for i, c in pairs(children) do
if c:IsA("ClickDetector") then
print("FoudnClickDetector")
return end
end
print("Clicked!")
end
end)