Yes but you have to have 2 copies of the function which is unintuitive.
local function SetupButton(Button)
if v:IsA("TextButton") then
v.MouseButton1Down:Connect(function()
print("A unnamed TextButton were clicked!")
end)
end
end
for i,v in pairs(game.StarterGui:GetDescendants())
SetupButton(v)
end
YourGui.ChildAdded:Connect(function(v) -- ?? I think childadded works in a localscript?
SetupButton(v)
end)
Instance.new("TextButton")
In my opinion, Iād rather use normal roblox api over a module.
local interfaceService = require(game.ReplicatedStorage:WaitForChild("InterfaceService"))
setupButton = interfaceService:Get(".TextButton", game.StarterGui).LeftClick(function(this)
print(this.Name.." Was Clicked")
end)
YourGui.ChildAdded:Connect(function(v)
setupButton:Update()
end
Instance.new("TextButton")
your code is 17 lines whilst mine is 9. Your code is almost double the size of mine. My module is the more intuitive option, but fair enough if you want to use Robloxās API.
That is true, Iām sure your module is better than roblox api on some cases, But i just wanted to point out that this CAN be done by roblox API.
What would make it better than just having a dedicated function to it?
local connectedInteractions = {}
local function updateEvents(location, callbackFunction)
for _, Interactions in pairs(location:GetDescendants()) do
if not table.find(connectedInteractions, Interactions) and (Interactions:IsA('ImageButton') or Interactions:IsA('TextButton')) then
Interactions:Connect(callbackFunction)
table.insert(connectedInteractions, Interactions)
end
end
end
Why did you want to point that out. Obviously you can do it with Robloxās API as my module is basically a wrapper for robloxs api
I pointed this out to tell you that this module is practically useless, It doesnāt really bring anything new and i feel like it doesnāt help a lot, If anything i think robloxās normal API is easier to use.
fair enough, we are all entitled to our opinions.
guis should not be made in code when thereās easy to use ui tools available
I would disagree. There are plenty of use cases for constructing ui in code - such as making a morph gui and having code create a button for each morph in a folder located in replicatedstorage. Plus I only have 1 function dedicated to creating ui objects, most of the functions are for scripting gui interactions (if you actually looked at this posts title you would know this).
i didnāt mean cloning existing gui objects, i meant creating whole guis in code.
either way, creating guis bigger than a single button can make the code look quite messy and unreadable.
Well, pretty good documentation. So thatās a plus. Personally not a fan of the syntax, or find a single practical use case for such niche functionality though.
Could you elaborate on why? Im planning on completely redoing the module to make it more functional.
Since you asked me to elaborate on why Iām personally not a fan of the syntax or practical usage
From the looks of it, the focus of this module was redundancy reduction and time-saving
(ex: you donāt have to use a for loop we can connect to every Instance of X class using this handy module!)
Yet so much of this moduleās API is redundant or time-wasting. Iād much rather use regular Roblox API or alternative modules. At best, Iād heavily modify nearly every function.
Manual Update() calls⦠From my perspective are often completely redundant in usage.
You often call it simply due to the Create method lacking an internal call.
You could just call :Update() internally every time the Create method is used and heavily reduce its usage if not eliminate it entirely.
Why would your Create API require a Table containing a ClassName property, when ClassName must ALWAYS be an argument? Just allow someone to pass the ClassName as the first argument akin to the Roblox Instance.new(ClassName) method. It saves you an entire table declaration; (which if you ever forget to include: suffer.), several characters, and loads of readability issues as you can pick up on the instance youāre actually creating in the first parameter that way, and then specify other traits as need be in the following table.
I have more grievances. But thatās the gist of my criticism. Do with it what you will.
I changed my name on Github which meant the documentation url changed. here is the new documentation url ā https://cameroncampbell05.github.io/InterfaceService/
Collection Service can be used for this. No need to create a module when you can pair collection service and a loop.