Hi, my script doesnt destroy the clone variable (is a textlabel) but it prints the clone destroyed line. The if game.ReplicatedStorage.Eng1OnFire.Value == true then line works. But the elseif game.ReplicatedStorage.Eng1OnFire.Value == false then line doesnt. Any help?
game.ReplicatedStorage.Eng1OnFire.Changed:Connect(function()
local clone = script.Parent.Msg:Clone()
if game.ReplicatedStorage.Eng1OnFire.Value == true then
clone.Text = 'Eng 1 Fire'
clone.Parent = script.Parent.Failures.Frame
clone.TextColor = BrickColor.Red()
elseif game.ReplicatedStorage.Eng1OnFire.Value == false then
clone:Destroy()
print('clone destroyed')
end
end)
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local Engine1 = ReplicatedStorage.Eng1OnFire
local Engine2 = ReplicatedStorage.Eng2OnFire
local APU = ReplicatedStorage.APUOnFire
--//Initialization
local clone = script.Parent.Msg:Clone()
local clone2 = script.Parent.Msg:Clone()
local clone3 = script.Parent.Msg:Clone()
--//Functions
Engine1:GetPropertyChangedSignal("Value"):Connect(function()
if Engine1.Value then
if not clone then
clone = script.Parent.Msg:Clone()
end
clone.Text = 'Eng 1 Fire'
clone.TextColor = BrickColor.Red()
clone.Parent = script.Parent.Failures.Frame
else
clone:Destroy()
clone = nil
end
end)
Engine2:GetPropertyChangedSignal("Value"):Connect(function()
if Engine2.Value then
if not clone2 then
clone2 = script.Parent.Msg:Clone()
end
clone2.Text = 'Eng 2 Fire'
clone2.TextColor = BrickColor.Red()
clone2.Parent = script.Parent.Failures.Frame
else
clone2:Destroy()
clone2 = nil
end
end)
APU:GetPropertyChangedSignal("Value"):Connect(function()
if APU.Value then
if not clone3 then
clone3 = script.Parent.Msg:Clone()
end
clone3.Text = 'APU Fire'
clone3.TextColor = BrickColor.Red()
clone3.Parent = script.Parent.Failures.Frame
else
clone3:Destroy()
clone3 = nil
end
end)
(I also polished your script a bit and made it more readable)