Does " :Once " mean that the given code will run once only, and it can’t run again even if the player rejoined?
:Once()
runs it’s callback once and then disconnects. it’s equivalent to:
local connection
connection = something.Event:Connect(function()
connection:Disconnect()
...
end)
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.
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
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.
local IsSoundPlayed = false
Part.touched....
if IsSoundPlayed then return end
IsSoundPlayed = true
Sound:Play
end)
Alright thanks!
[PLSLETMEPOSTPLSSSS]