Stop TextLabel from flashing?

Hello! Currently I have this:


And this is the code:

local Event = game.ReplicatedStorage:WaitForChild("Notify")

--

Event.OnClientEvent:Connect(function(text)
	script.Parent.Text = text
	script.Parent.Visible = true
	task.wait(1)
	script.Parent.Visible = false
end)

The text keeps flashing because the event can fire mulitple times within the task.wait(1), causing a mess.

Is there anyway I can stop it and actually make it disappear after 2 seconds instead of flashing?

When you touch it, before firing the remote event, could you make a conditional (if-statement) that script.Parent.Visible must be false? Because if it’s true, you know it would be actively counting down.

Try to add the debounce.

local Event = game.ReplicatedStorage:WaitForChild("Notify")

--
local db = false
--

Event.OnClientEvent:Connect(function(text)
	script.Parent.Text = text
    if db then return end
    db = true
	script.Parent.Visible = true
	task.wait(1)
	script.Parent.Visible = false
    db = false
end)
1 Like

That works perfectly, thanks.

new code:

local Event = game.ReplicatedStorage:WaitForChild("Notify")

--

Event.OnClientEvent:Connect(function(text)
	script.Parent.Text = text
	if script.Parent.Visible == false then
		script.Parent.Visible = true
		task.wait(1)
		script.Parent.Visible = false
	end
end)