hello, i wanna optimize my script so its didnt need 1 script/gui but i think the 1 script/gui is better
this is the workspace
this is the difference
optimized version (I guess)
local monitormodule = require(game.ReplicatedStorage.shop.monitor.monitor)
local clicksound = game.ReplicatedStorage.sound.click
local player = game.Players.LocalPlayer
local hover = game.ReplicatedStorage.sound.hover
local normalsize = script.Parent.agedmonitor.Size
local normalposition = script.Parent.agedmonitor.Position
local cooldown = false
local looping = false
function click(imagebutton : ImageButton)
if cooldown == false then
cooldown = true
rightscreeninfo.Image = imagebutton.Image
rightscreeninfo.info.Text = "Increase FPS/s by "..monitormodule["active"][imagebutton.Name].." (ACTIVE)"
rightscreeninfo.info2.Text = "Increase FPS/s by "..monitormodule["pasive"][imagebutton.Name].." (PASSIVE)"
script.RemoteEvent:FireServer(imagebutton)
clicksound:Play()
task.wait(0.1)
cooldown = false
end
end
function mouseenter(imagebutton, size)
imagebutton:TweenSize(normalsize - UDim2.new(0.01, 0.01, 0.01, 0.01), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
imagebutton:TweenPosition(normalposition + UDim2.new(0.005, 0.005, 0.005, 0.005), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
hover:Play()
repeat
task.wait(0.01)
imagebutton.MouseLeave:Connect(function()
task.wait(0.1)
imagebutton:TweenSize(normalsize, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
imagebutton:TweenPosition(normalposition, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
looping = false
end)
until size == normalsize
end
while script.Parent.Parent.Visible do
task.wait(0.1)
for _, imagebutton : ImageButton in pairs(script.Parent:GetChildren()) do
if imagebutton:IsA("ImageButton") then
imagebutton.MouseButton1Click:Connect(function()
click(imagebutton)
end)
local size = imagebutton.Size
imagebutton.MouseEnter:Connect(function()
if looping == false then
mouseenter(imagebutton, size)
end
end)
end
end
end
un optimized:
local position = script.Parent.Position
local player = game.Players.LocalPlayer
local hover = game.ReplicatedStorage.sound.hover
script.Parent.MouseEnter:Connect(function()
script.Parent:TweenSize(size - UDim2.new(0.01, 0.01, 0.01, 0.01), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
script.Parent:TweenPosition(position + UDim2.new(0.005, 0.005, 0.005, 0.005), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
hover:Play()
end)
script.Parent.MouseLeave:Connect(function()
wait(0.1)
script.Parent:TweenSize(size, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
script.Parent:TweenPosition(position, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
end)
local monitormodule = require(game.ReplicatedStorage.shop.monitor.monitor)
local valueformat = require(game.ReplicatedStorage.valueformat)
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.sound.click:Play()
local toolname = script.Parent.TextLabel.Text
rightscreeninfo.Image = script.Parent.Image
rightscreeninfo.info.Text = monitormodule["pasive"][script.Parent.Name].."% fps cooldown decrease (Passive)"
rightscreeninfo.info2.Text = monitormodule["active"][script.Parent.Name].."% fps cooldown decrease (Active)"
local leaderstatsmodule = require(game.ReplicatedStorage.leaderstats)
function multiplication(n, framebit, framebitecheck)
if n == 1 or n <= 0 then
return 10
else
return multiplication(n - 1) * 1000
end
end
local framebit = monitormodule["price"][script.Parent.Name]
local framebitstring = string.format("%f", monitormodule["price"][script.Parent.Name]):split(".")[1]
local framebitecheck = #tostring(framebit):split("e") - 1
local framebitstring = tostring(framebitstring):reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "")
local framebitstringtotal = #framebitstring:split(",") - 1
local result = multiplication(framebitstringtotal, framebit, framebitecheck)
local result2 = tostring(math.floor(framebit/result)):reverse():gsub("^%d%d", "%1,"):reverse()
rightscreeninfo.buy.Text = result2..valueformat[tostring(framebitstringtotal)]
local buyprice = monitormodule["price"][script.Parent.Name]
script.Parent.Script.RemoteEvent:FireServer(buyprice, toolname)
end)
script.RemoteEvent.OnServerEvent:Connect(function(player, buyprice, toolname)
rightscreeninfogui.buy.price.Value = buyprice
rightscreeninfogui.name.Text = toolname
rightscreeninfogui.buy.toolname.Value = script.Parent.Name
end)
so which one better for performance? sorry if the script very messy