Would recommend using .Activated event instead of .MouseButton1Click for the button, which has mobile support. Also explain in detail your code like others said. Still, cool resource for starter scripters.
local Button = script.Parent
local Check = Button.Check
local something = workspace -- Variable, naming the part
Button.MouseButton1Click:Connect(function()
if Check.Visible == false then
something.Brickcolor = Brickcolor.new("Lime Green") -- Making that part really red
Check.Visible = true
elseif Check.Visible == true then
something.Brickcolor = Brickcolor.new("Really Red")
Check.Visible = false
end
end -- end of the code
local Button = script.Parent
local Check = Button.Check
local falseColor = Color3.new(0.333333, 1, 0)
local trueColor = Color3.new(1, 0, 0)
Button.Activated:Connect(function()
Check.Visible = not Check.Visible
Checked.Text = Checked.Text == "Checked" and "Not checked" or "Checked"
Checked.TextColor3 = Checked.TextColor3 == falseColor and trueColor or falseColor
end
We removed 6 lines with ternary so we removed 80% (the previous code had 20 lines, mine has only 16, 16 / 20 * 100 = 80) of the previous code’s lines. You can use the luau’s official ternary instead of the fake one I used, but wanted to point out that save.