Hello. I have a PlayerManager
module, it controls events for every player such as:
Joining, leaving, loading, data, remotes, etc
Is this code I have fine? Or should I not be disconnecting these?
Ignore the playerJoinConnection and playerLeaveConnection
playerJoinConnection = Players.PlayerAdded:Connect(function(player)
print("\nPlayer joined. Username:", player.Name)
Manager.playerStorage[player.Name] = {}
local PlayerTable = Manager.playerStorage[player.Name]
PlayerTable.Connections = {}
PlayerTable.Stats = {}
PlayerTable.Stats.isSpawned = false
local Character = player.Character or player.CharacterAdded:Wait()
PlayerTable.Connections.characterRemovedConnection = player.CharacterRemoving:Connect(function(character)
humanoidConnectionRemote:FireClient(player, true)
PlayerTable.Stats.isSpawned = false
end)
PlayerTable.Connections.characterAddedConnection = player.CharacterAdded:Connect(function(character) -- TEMP
humanoidConnectionRemote:FireClient(player, false)
PlayerTable.Stats.isSpawned = true
end)
end)
playerLeaveConnection = Players.PlayerRemoving:Connect(function(player)
print("\nPlayer leaving, disconnecting connections.")
for _, connection in Manager.playerStorage[player.Name].Connections do
connection:Disconnect()
end
table.clear(Manager.playerStorage[player.Name])
Manager.playerStorage[player.Name] = nil
end)
This isn’t the entire script, only the part I have questions for, I don’t want to leave my source for everything else out
The other stuff isn’t connections so it wouldn’t matter anyway