I would like to run a check to see if the attachment is present unfortunately this just doesn’t work out the way I would like anyone any ideas
yours sincerely,
Technical_D
---------------------- Brakes ----------------------
function module:BrakesOn(L, ClrBr, ClrB)
for i = 1,#L do
if string.find(L[i].Name, "BR_") then
L[i].BrickColor = BrickColor.new(ClrBr)
L[i].Material = Enum.Material.Neon
L[i].Attachment.light.Enabled = true
end
end
end
function module:BrakesOff(L, ClrBr, ClrBrO, ClrB)
for i = 1,#L do
if string.find(L[i].Name, "BR_") and string.find(L[i].Name, "Back_") then
L[i].BrickColor = BrickColor.new(ClrB)
L[i].Material = Enum.Material.Neon
elseif string.find(L[i].Name, "BR_") then
L[i].BrickColor = BrickColor.new(ClrBrO)
L[i].Material = Enum.Material.SmoothPlastic
L[i].Attachment.light.Enabled = false
end
end
end
function module:BrakesOn(L, ClrBr, ClrB)
for i = 1,#L do
if string.find(L[i].Name, "BR_") then
L[i].BrickColor = BrickColor.new(ClrBr)
L[i].Material = Enum.Material.Neon
if L[i][Attachment] then
L[i].Attachment.light.Enabled = true
end
end
end
end
function module:BrakesOff(L, ClrBr, ClrBrO, ClrB)
for i = 1,#L do
if string.find(L[i].Name, "BR_") and string.find(L[i].Name, "Back_") then
L[i].BrickColor = BrickColor.new(ClrB)
L[i].Material = Enum.Material.Neon
elseif string.find(L[i].Name, "BR_") then
L[i].BrickColor = BrickColor.new(ClrBrO)
L[i].Material = Enum.Material.SmoothPlastic
if L[i][Attachment] then
L[i].Attachment.light.Enabled = false
end
end
end
end
Alternatively, you could use L[i]:FindFirstChild(“Attachment”). I would also reccomend giving a more precise name to the attachment holding the light, such as ‘LightAttachment’.