An inquiry about " :Once "

Does " :Once " mean that the given code will run once only, and it can’t run again even if the player rejoined?

1 Like

:Once() runs it’s callback once and then disconnects. it’s equivalent to:

local connection

connection = something.Event:Connect(function()

however, you’re going to need to provide more context with regards to this. what are you trying to achieve?


I’m trying to make the code run once only.

edit: gonna be afk

So like it only plays once FOREVER? If so you could prolly save some sort of value in a DataStore or database.

Then you could check if if that value is false (hasn’t ran the function for the player) and run the :Once function you have and then change the value to true and save it ofc.

1 Like

Your code only runs once unless you wrap it in an event or a loop anyway.
You’re gonna need to be more descriptive about what you’re trying to do.


I just want the sound to play ONCE when the part is touched, and it never plays again.

edit: going afk for hours

1 Like

Then yes, using Part.Touched:Once() on the server would work, but not cross-server. If you wanted to do that you’d need to use datastores, like others have said.

1 Like
local IsSoundPlayed = false

if IsSoundPlayed then return end
 IsSoundPlayed = true
1 Like

Alright thanks!