Player & Global State
RoundKit provides two registries for round state:
PlayerStateRegistrystores state for individual players.GlobalMetricRegistrystores state shared by the entire round.
Use these instead of loose variables or Player attributes.
Player state
Each tracked player has a PlayerRoundState. A state is created explicitly with context:AddPlayerState(), or indirectly through your own player management code.
manager:OnPlayerJoined(function(context, player)
local state = context:AddPlayerState(player)
state:SetReady(true)
end)
A PlayerRoundState contains:
Player- the associatedPlayer.UserId- the player's user ID.Connected- whether the player is currently connected.Ready- used by helper methods such ascontext:GetReadyPlayerCount().Metrics- a key/value store for game-specific data.
state:SetMetric("Kills", 0)
state:SetMetric("Alive", true)
local kills = state:GetMetric("Kills")
Most game code accesses player state through Context rather than holding a PlayerRoundState directly.
context:GetMetric(player, "Kills")
context:GetPlayerState(player.UserId)
context:GetPlayers()
context:GetReadyPlayerCount()
Use context:RemovePlayerState(userId) to stop tracking a player completely. This removes the player's state from the round. It does not mark them as disconnected.
AutoWirePlayers
RoundKit.new({
...
AutoWirePlayers = true,
})
When enabled, RoundKit connects to Players.PlayerAdded and Players.PlayerRemoving automatically, forwarding those events to the round manager.
AutoWirePlayers does not create player states automatically. It only invokes the corresponding round callbacks, allowing your game to decide which players should be tracked.
If disabled, call manager:OnPlayerAdded(player) and manager:OnPlayerRemoving(player) yourself.