Hey everyone,
I have a quick question: Is It possible to use MouseButton1Click on Frame
and If not what are the alternatives for MouseButton1Click on frame
Thanks for reading.
Hey everyone,
I have a quick question: Is It possible to use MouseButton1Click on Frame
and If not what are the alternatives for MouseButton1Click on frame
Thanks for reading.
There is no RBXScriptSignal
for MouseButton1Click on a frame, no. Though you could use UserInputService but I cannot guarantee you, that you will get the best results
No, it’s not possible, you should check for another way to conect the MouseButton1Click.
Best alternative is to make transparent button all over the frame.
Haha I had this idea in mind… but there is areas It can’t cover
Well only GuiObjects that have MouseButton1Click signal are TextButton, ImageButton.
Whoops, there is a way!
You could listen for the InputBegan event on a frame;
local Frame = script.Parent
Frame.InputBegan:Connect(
function(InputObject)
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then
...
end
end
)
This will work only for PC (just saying) but great idea how to go around this.
If you want to create a sort of custom button for whatever reason, you can first detect if the mouse ishovering over the frame. If so, respond whenever the mouse clicks.
local MouseHovering = false
local Frame = path.to.frame
local function OnFrameClicked()
print("Click!")
end
Frame.MouseEnter:Connect(function ()
MouseHovering = true
end)
Frame.MouseLeave:Connect(function ()
MouseHovering = false
end)
game:GetService("UserInputService").InputEnded:Connect(function (input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and MouseHovering then
OnFrameClicked()
end
end)
Note this doesn’t detect mobile input. I’m just sharing this with you to get you started! (This also isn’t tested in Roblox Studio)
This should work on mobile [NOT TESTED]
Read the reply this doesn’t work
local Frame = script.Parent
local marketplace = game:GetService("MarketplaceService")
Frame.InputBegan:Connect(
function(InputObject)
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 or Enum.UserInputType.Touch then
...
end
end
)
You can just put an invisible textbutton over it if you really want
That wouldn’t work because of how or
operates.
Just do:
if table.find({Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch}, InputObject.UserInputType) then
oh, sorry. I am kind of new to this.
Oh perfectly! Nice idea, U explain this perfectly!
i know this post is old but isnt it simpler to just do
if InputObject.UserInputType == Enum.UserInputType.MouseButton1 or InputObject.UserInputType == Enum.UserInputType.Touch then
instead ?
You could do that if you want; I like to use table.find if I’m detecting a large number of different inputs
i see, although i havent found much use to it myself, ill be reading up on table functions since i do admit i dont know much about them