I'm trying to make my text label appear then disappear and then appear once enabled is set to true on my screengui

the script does work but when my screen gui gets set back to false the transparency remains at 1 once even when i open and close the transparency stays the same but once i leave and rejoin it starts working again.

Here's the script that i'm using:

local TextLabel = game.Players.LocalPlayer.PlayerGui.NPCChat.ChatBox.TextLabel

if game.Players.LocalPlayer.PlayerGui.NPCChat.Enabled == true then game.Players.LocalPlayer.PlayerGui.NPCChat.ChatBox.TextLabel.LocalScript.Disabled = false

repeat

TextLabel.BackgroundTransparency = 0

wait(0.5)

TextLabel.BackgroundTransparency = 1

wait(0.5)

TextLabel.BackgroundTransparency = 0

wait(0.5)

TextLabel.BackgroundTransparency = 1

wait(0.5)

until game.Players.LocalPlayer.PlayerGui.NPCChat.Enabled == false

else if game.Players.LocalPlayer.PlayerGui.NPCChat.Enabled == false then game.Players.LocalPlayer.PlayerGui.NPCChat.ChatBox.TextLabel.LocalScript.Disabled = true

end

end