How could I improve my Script so the same can be even more powerful and optmized? It is a LocalScript inside of a frame that is inside of a ScreenGUI called “Menu”. What could I do to make that readeable and powerful? Thank you in advance.
local Gui = script.Parent
local plr = game.Players.LocalPlayer
local TS = game:GetService("TweenService")
local tweens = TS:Create(Gui.BlackFrame.WhiteFrame,TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Transparency = 0})
local uses,maxuses = 0,1
local used = false
local TrueMenu = Gui.TrueMenu
local rgb = Color3.fromRGB
local function PlaySound(sound)
sound:Play()
end
for _,v in pairs(Gui:GetDescendants()) do
if v.ClassName == "TextButton" then
v.MouseEnter:Connect(function() -- When mouse Enter Function
while v.MaxVisibleGraphemes == 0 do wait() end
PlaySound(script.Text2)
local dt = Gui.BlackFrame.Determination
v.TextColor3 = rgb(255, 247, 22)
v.BorderColor3 = rgb(255, 247, 22)
dt.Parent = v
dt.ImageTransparency = 0
end)
v.MouseLeave:Connect(function()
while v.MaxVisibleGraphemes == 0 do wait() end
v.TextColor3 = rgb(255,255,255)
v.BorderColor3 = rgb(255,255,255)
local dt = v:WaitForChild("Determination", 3)
dt.ImageTransparency = 1
dt.Parent = Gui.BlackFrame
end)
v.MouseButton1Click:Connect(function()
if TrueMenu.Value == false then
while used == false do
used = true
local Debris = game:GetService("Debris")
local textbox = Gui:WaitForChild("Do not Be Silly, Kiddo."):Clone()
textbox.Parent = Gui.BlackFrame
Debris:AddItem(textbox,1.7)
for i = 1, string.len(textbox.Text) do
textbox.MaxVisibleGraphemes = i
task.wait(0.05)
end
used = false
return
end
return
end
while v.MaxVisibleGraphemes == 0 do wait() end
if uses == maxuses then return end
uses += 1
print("Used in "..tostring(v).."! Have fun Player!")
local sound1,sound2,sound3 = script.Text3,script.Text4,script.Text5
if v.Name == "Play" then
PlaySound(sound1)
elseif v.Name == "Credits" then
PlaySound(sound2)
elseif v.Name == "Tutorial" then
PlaySound(sound3)
end
tweens:Play()
PlaySound(script.Text6)
wait(6.8)
Gui.Enabled = false
wait(2)
Gui.Parent:Destroy()
end)
end
end