Hello, I’d like to find out if datastore2 auto disconnects the :OnUpdate connection.
So this is what I’ve been using for a while:
datastore2("Value",player):OnUpdate(function(newValue)
-- code
end)
And I’ve been wondering if I should replace it with this:
local listOfConnections = {}
players.PlayerAdded:Connect(function(player)
local connection
connection = datastore2("Value",player):OnUpdate(function(newValue)
-- code
end)
listOfConnections[player.UserId] = connection
end)
players.PlayerRemoving:Connect(function(player)
listOfConnections[player.UserId]:Disconnect()
end)
The main reason I want to know why it disconnects or not is to avoid memory leaks.
Thanks.