I want to make a custom event similar to .Activated
in order to connect GUI’s to functions. My problem with .Activated
is that it needs ImageButton.Active = true
in order to function. This .Active
property blocks UserInputService events, like ScrollingFrame.InputBegan
.
I presume object-oriented is the way here, but I don’t know much about metatables and metafunctions.
This is what I have:
function GuiModule.Click(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
return true
else
return false
end
end
local GuiModule = require(game.Players.LocalPlayer.PlayerGui.GuiModule)
GuiButton.InputEnded:Connect(function(Input)
if GuiModule.Click(Input) then --I really have to write an if statement for every InputEnded event?
print("Button clicked")
end
end)
This is my ideal solution, where I can choose which UserInputService buttons and keys activate .Clicked
on various platforms:
GuiButton.Clicked:Connect(function(Input)
print("Button clicked")
end)