I am starting doing thi type of post to see what I could’ve done with my script to make it better, organized and optimized.
--[[VARIABLES]]--
local Frame = script.Parent
local information = script.Parent.Information
local star = Frame.Information.SaveStar
local image1,image2,image3,image4 = Frame.Bone1,Frame.Bone2,Frame.Bone3,Frame.Bone4
local tween = game:GetService("TweenService")
local corount = coroutine.wrap
local Childrens = script.Parent:GetChildren()
local offset = 0
local sound = Frame.Selection
--[[TABLES]]--
local images = {image1,image2,image3,image4}
--[[FUNCTIONS]]--
local function PlayTween(tween : Tween)
tween:Play()
end
local function RotateImage()
while task.wait(math.random(1,10)) do
local random = images[math.random(1,#images)]
local rotate = tween:Create(random,TweenInfo.new(1.5,Enum.EasingStyle.Circular,Enum.EasingDirection.Out),{Rotation = random.Rotation + 360})
PlayTween(rotate)
end
end
local function RotateStar()
local rotateStar = tween:Create(star,TweenInfo.new(2.25,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1),{Rotation = star.Rotation + 360})
PlayTween(rotateStar)
end
local function Tween(object : Instance, Position : UDim2)
local info = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, -1, true, 0)
local property = {
Position = Position
}
local pos = tween:Create(object,info,property)
PlayTween(pos)
end
local function MouseEnter(object : Instance,color : Color3)
object.BorderColor3 = color
end
local function MouseLeave(object : Instance,original : Color3)
object.BorderColor3 = original
end
for _,v in pairs(information:GetChildren()) do
if v:IsA("TextButton") then
local fromRGB = Color3.fromRGB
local color = fromRGB(255,255,0)
local original = v.BorderColor3
v.MouseEnter:Connect(function()
MouseEnter(v,color)
sound:Play()
end)
v.MouseLeave:Connect(function()
MouseLeave(v,original)
end)
end
end
--[[Threads]]--
task.spawn(RotateImage)
task.spawn(RotateStar)
local core1 = corount(Tween)(image1,UDim2.new(0.015,offset,0.1,offset))
local core2 = corount(Tween)(image2,UDim2.new(0.985,offset,0.9,offset))
local core3 = corount(Tween)(image3,UDim2.new(0.05,offset,0.045,offset))
local core4 = corount(Tween)(image4,UDim2.new(0.95,offset,0.96,offset))