Recently I experienced with InputBegan firing on sank GUI’s, and I didn’t find a solution to it, but instead made one.
local module = {}
local Inputed = {}
local CurrentIndex = 0
local OnTop = nil
module.Connect = function(object, callback)
object.InputBegan:Connect(function(inp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
table.insert(Inputed, object)
wait()
for _, ob in pairs(Inputed) do
if ob.ZIndex > CurrentIndex then
CurrentIndex = ob.ZIndex
OnTop = ob
end
end
wait()
if OnTop == object then
callback(inp)
end
CurrentIndex = 0
OnTop = nil
Inputed = {}
end
end)
end
return module
Just make module script, put this in, require it, and use it.
(This is only for M1, feel free to change)
Usage:
local Input = require(module)
local Frame = script.Parent
Input.Connect(Frame, function(inp)
if not inp.UserInputType == Enum.UserInputType.MouseButton1 then return end
print("Clicked")
end)
Also Roblox, from this solution, I expect a one million dollar payment for this solution.
My bank: LT9218294873349
local HttpService = game:GetService("HttpService")
local module = {}
local Regs = {}
module.Register = function()
Regs[HttpService:GenerateGUID(false)] = {}
end
module.Connect = function(object, callback)
for Id, _d in Regs do
if typeof(_d) == "table" then
local private = {}
local Inputed = {}
local CurrentIndex = 0
local OnTop = nil
_d = object.InputBegan:Connect(function(inp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
table.insert(Inputed, object)
for _, ob in pairs(Inputed) do
if ob.ZIndex > CurrentIndex then
CurrentIndex = ob.ZIndex
OnTop = ob
end
end
if OnTop == object then
task.spawn(callback, inp)
end
CurrentIndex = 0
OnTop = nil
Inputed = {}
end
end)
private.Disconnect = function()
if Regs[Id] and _d then
_d:Disconnect()
Regs[Id] = nil
end
end
return table.freeze(private)
end
warn("Failed to connect, Have you Registered a new?")
end
return table.freeze(module)
sorry if the code not format cuz i wrote it on phone. i added Register so you can use multiple times and Disconnecting but i havent test it.