My game’s inventory GUI works perfectly fine at the moment- However, I’m trying to make a function fire when each inventory item’s tab is clicked. The function works fine, but firing it is the problem. Putting a script in each little inventory tab is problematic and laggy, but I don’t know how to have it all be handled in my GUI control script. I’d appreciate any help. Thanks ![]()
To streamline several scripts into one, consider placing the script on the very outer scope of the hierarchy and then write different functions for respective functionalities, where the essential one is for toggling the UIs visibility. Before declaring functions, declare the references of the UI buttons.
This enables you to write a UI logic where you can open one window at a time per “scope”.
My suggestion is to put all your inventory tabs in a folder, then create a variable, let’s say local count = 0, and then add a table containing all the tabs, maybe you can do it with:
for i,v in pairs(Folder:GetChildren()) do
v.MouseButton1Click:Connect(function() count = count + 1 end)
end
Everytime check if a variable has a certain value (based on the number of inventory tabs), and then simply run your code. Tell me if you didn’t understand something.
What is the point of having a count? I don’t see a purpose in it.
To keep track of how many inventory tabs have been clicked