All other gui’s in the game have open/close but a scripter off mine said that
Usually, you can fit multiple loops into one loop by rewriting it, you need your scripters to read how to make lua code more efficiency lua.org has a paper all about this here.
So Off what ive seen is I can have 1000’s off gui’s and then it would lag a little?
Opening and closing GUI’s can be done by one script instead of multiple. Roblox has tutorials on how this can be achieved. If you need to know more than just one script does all, see here:
Ill have a look on that soon! I have multiple scripts in different frames just to close the frame
Here’s the closest I could find which you and your programmers may be interested in reading:
If i was to have all the closes in the same script how much could it help on RAM?
For a simple open-close functionality, it wouldn’t be that helpful on RAM, but if one script can close and open multiple windows, so can it do much heavier tasks.
Large code can simply be done by one script instead of many copies of the massive code in many locations, but don’t go too overboard with that. Also, it’s not only the way you write code, but the way code handles RAM. If you were to store a massive table, or you don’t properly clean data, you’d immediately fill up RAM.
Ok so im guessing i would have to locate where the buttons are to close it all in one script? so Having one script that does the same as multiple scripts is better?
A better approach would be to have the script make the windows instead. A simple way is to create a pre-made window with a close button. Then, every time a new window is made, get its close button, connect a function to it, and parent it on the main UI. Simple code could be like this, just to give you an idea:
local Premade_Window : Frame = game:GetService("ReplicatedStorage"):WaitForChild("Window") -- Let's say you have your Window object under ReplicatedStorage.
local This_Player = game:GetService("Players").LocalPlayer
local function New_Window()
local Window = Premade_Window:Clone()
local Close_Button : TextButton = Window.Close
Close_Button.MouseButton1Click:Connect(function()
Window.Visible = false -- If you want to retrive the window, just hide it.
end)
Window.Parent = This_Player.PlayerGui.WhateverScreenGuiName
return Window
end
local Test_Window = New_Window()
You may have to change some existing code.
Also, I recommend you check out ModuleScripts.
So it makes a new window/existing one?
Yes. This should be instead used in a module so other scripts can access its functions. Check out the link I provided if you want to learn about modules.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.