local functionsModule = require(script.Functions)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local shopUI = playerGui:WaitForChild("ShopUI")
local sideUI = playerGui:WaitForChild("SideUI")
local upgradeUI = playerGui:WaitForChild("UpgradeUI")
local shopMain = shopUI:WaitForChild("Frame")
local categories = shopMain.Categories.ButtonBar
local itemFrame = shopMain.Items.ItemsFrame
local passes = shopMain.Passes.GamepassFrame
local viewFrames = shopMain.ViewFrames
for _, frame in ipairs(itemFrame.ScrollingFrame:GetChildren()) do
if frame:IsA("ImageLabel") then
local viewBTN = frame.BuyFrame:FindFirstChildWhichIsA("TextButton")
local strings = {"MedKit", "Crowbar", "Backpack", "KeyDetector"}
viewBTN.Activated:Connect(function()
functionsModule.viewItemFrame(viewFrames[viewBTN.Parent.Parent.Name])
end)
functionsModule.levelHandle(unpack(strings))
end
end
for _, categoryFrame in ipairs(categories:GetChildren()) do
if categoryFrame:IsA("ImageLabel") then
local viewBTN = categoryFrame:FindFirstChildWhichIsA("TextButton")
viewBTN.Activated:Connect(function()
functionsModule.changeCategoryColor(categoryFrame, viewBTN.Parent)
functionsModule.viewCategoryFrame(shopMain[viewBTN.Parent.Name]:FindFirstChildWhichIsA("ImageLabel"))
end)
end
end
for _, frame in ipairs(viewFrames:GetChildren()) do
if frame:IsA("ImageLabel") then
local backBTN = frame:FindFirstChild("BackFrame"):FindFirstChildWhichIsA("TextButton")
backBTN.Activated:Connect(function()
functionsModule.viewBack()
end)
end
end
for _, frame in ipairs(sideUI:GetChildren()) do
if frame:IsA("ImageLabel") and frame.Name ~= "Points" then
local button = frame:FindFirstChildWhichIsA("TextButton")
local strings = {"UI"}
button.Activated:Connect(function()
functionsModule.changeButtonColor(button.Parent)
functionsModule.viewScreenGUI(playerGui[button.Parent.Name.. unpack(strings)])
end)
end
end
local pointsAmt = sideUI.Points.PointAmount
functionsModule.updateText(pointsAmt)
player.leaderstats.Points.Changed:Connect(function()
functionsModule.updateText(pointsAmt)
end)
return functionsModule
It’s as good as it can get mostly but one thing you can do is since you only use some variables so you can iterate through its children, just set the variable to the childrens array instead.
Example: local categories = shopMain.Categories.ButtonBar:GetChildren()
In here, you unpack that defined table of “UI” for some reason as concatenation. This seems highly redundant as you can just attach “UI” itself for concatenation instead of unpacking a table into a tuple.
Alright did, just didn’t updated the script.
Do you think that my script is efficient?
Even if there are small changes to be made, please do let me know.
Yeah I let you know that small change was the unpacking the table part used for concatenation.
Otherwise, it’s pretty efficient in terms that you can’t really get any negligently better performance-wise.
Alright thanks. ( 30 characters)