I want to make it so my mouse can only click on places that aren’t ui objects. Is it possible?
This is definitely possible. If they aren’t text buttons you could disable them for that moment. with a Boolean or something.
Could you add a bit more context for me?
I am making a clicker game and i don’t want to get clicking effects to appear when my mouse is on ui, since it will be annoying. So that is basically what i want to do
If you want to ensure that the mouse is hovering over a gui Element, PlayerGui has a function called :GetGuiObjectsAtPosition(). Here is a LocalScript that will tell you if the mouse is on a gui element:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Move:Connect(function()
local MousePos = game:GetService("UserInputService"):GetMouseLocation() - game:GetService("GuiService"):GetGuiInset()
local getGUI = Player:WaitForChild("PlayerGui"):GetGuiObjectsAtPosition(MousePos.X,MousePos.Y)
if #getGUI ~= 0 then
print("hovering over a gui!")
end
end)
So far i can think only of making something like this:
script.Parent.ClickDetector.MouseClick:Connect(function(object)
if object:IsA("Frame") then
-- do nothing
elseif not object:IsA("Frame") then
print("tested")
end
end)
Or you can use ClassName.
I have never made a clicker game so im not sure how to structure it so i used a click detector.
Yeah this probably would work better than my idea.
I tried this, and it works thank you! ![]()
Even I learned something new! ![]()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.