I’ll get straight to the point here! i am still a near beginner scripter, and i have quite a few long scripts in my game, They work fine, and no real bugs from what i can see, but they are ungodly long and i think they are causing lag?
these longer ones specifically are client side, and are being used for coloring, if there is any efficient way to make these shorter and easier to read i would really like to know.
Basically what i am trying to achieve is when a color button is clicked in a specific section (split into Sleeves, torso and extras) it will color the part.
here’s a piece of the longer ones, this is NOT the full script as there are about 21k lines in the actual one.
script.Parent.Jacket["Torso"].Red.Color1.MouseButton1Click:Connect(function()
local Color = Color3.new(1, 0.87451, 0.882353)
r:FireServer(Color)
if game.Workspace["Clone morphs"]["false"]:FindFirstChild("jacket") then
game.Workspace["Clone morphs"]["false"].jacket.Chest.Color = Color
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Waist") then
game.Workspace["Clone morphs"]["false"].jacket.Waist.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Neck") then
game.Workspace["Clone morphs"]["false"].jacket.Neck.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra1") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra1.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra2") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra2.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra3") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra3.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra4") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra4.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra5") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra5.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra6") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra6.Color = Color
end
end
script.Parent.Jacket["Torso"].CurrentColor.BackgroundColor3 = Color
end)
script.Parent.Jacket["Torso"].Red.Color2.MouseButton1Click:Connect(function()
local Color = Color3.new(1, 0.615686, 0.639216)
r:FireServer(Color)
if game.Workspace["Clone morphs"]["false"]:FindFirstChild("jacket") then
game.Workspace["Clone morphs"]["false"].jacket.Chest.Color = Color
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Waist") then
game.Workspace["Clone morphs"]["false"].jacket.Waist.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Neck") then
game.Workspace["Clone morphs"]["false"].jacket.Neck.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra1") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra1.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra2") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra2.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra3") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra3.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra4") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra4.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra5") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra5.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra6") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra6.Color = Color
end
end
script.Parent.Jacket["Torso"].CurrentColor.BackgroundColor3 = Color
end)
script.Parent.Jacket["Torso"].Red.Color3.MouseButton1Click:Connect(function()
local Color = Color3.new(0.956863, 0.341176, 0.376471)
r:FireServer(Color)
if game.Workspace["Clone morphs"]["false"]:FindFirstChild("jacket") then
game.Workspace["Clone morphs"]["false"].jacket.Chest.Color = Color
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Waist") then
game.Workspace["Clone morphs"]["false"].jacket.Waist.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Neck") then
game.Workspace["Clone morphs"]["false"].jacket.Neck.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra1") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra1.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra2") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra2.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra3") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra3.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra4") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra4.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra5") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra5.Color = Color
end
if game.Workspace["Clone morphs"]["false"].jacket:FindFirstChild("Torsoxtra6") then
game.Workspace["Clone morphs"]["false"].jacket.Torsoxtra6.Color = Color
end
end
script.Parent.Jacket["Torso"].CurrentColor.BackgroundColor3 = Color
end)
if anyone can figure out how to optimize or shorten this script, it would be very much appreciated.