How can I do a break function?

Wussup guys I want that the InventoryButton appears again after the event is finished, first the button is Visible and when the Event starts it dissapears and that’s what I want but when the event finishes again it stays like that(I hope anyone understands this goofy text)here is the script:(I need a break function)

local button = script.Parent
local remote = game.ReplicatedStorage:WaitForChild(“DisplayRole”)

button.Visible = true

remote.OnClientEvent:Connect(function()
button.Visible = false
end)

I don’t understand

But if you only want the event to make it invisible once

Use :Once instead of :Connect

That happens because the script only runs once after the player joins the game.

If you want to make it visible after a couple of seconds you could add a wait() and make the button Visible again.

e.g.

remote.OnClientEvent:Connect(function()
button.Visible = false
wait(5)
button.Visible = true
end)

This way each time the event is fired it will trigger the visibility of the button.