Skip to content

Dont send after PlayerRemoving#223

Open
Ezzenix wants to merge 4 commits into
red-blox:0.6.xfrom
Ezzenix:player-leave
Open

Dont send after PlayerRemoving#223
Ezzenix wants to merge 4 commits into
red-blox:0.6.xfrom
Ezzenix:player-leave

Conversation

@Ezzenix

@Ezzenix Ezzenix commented May 2, 2026

Copy link
Copy Markdown
Contributor

Fix #216 by checking if player is still in player_map and also adding to player_map on PlayerAdded.

Comment thread zap/src/output/luau/server.rs Outdated
Comment on lines +1615 to +1626
self.push_line("for _, player in Players:GetPlayers() do");
self.indent();
self.push_line("load_player(player)");
self.push_line("player_map[player] = save()");
self.dedent();
self.push_line("end");
self.push_line("Players.PlayerAdded:Connect(function(player)");
self.indent();
self.push_line("load_player(player)");
self.push_line("player_map[player] = save()");
self.dedent();
self.push_line("end)");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unnecessary addition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are not added to player_map on join they will only be added after the server receives an event from the player, so zap would drop their requests before that. But i just noticed an issue, other scripts PlayerAdded will run before zaps so firing inside PlayerAdded would no longer work.

Comment thread zap/src/output/luau/server.rs Outdated
self.push_line(&format!("task.spawn(function(player_2, call_id_2, {args})"));
self.indent();

self.push_line("if player_map[player_2] == nil and player_2.Parent == nil then return end");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a performance optimisation, we should check if the player exists before spawning a task.

Comment thread zap/src/output/luau/server.rs Outdated
self.push(")\n");
self.indent();

self.push_line(&format!("if player_map[{player}] == nil and {player}.Parent == nil then return end"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return in places it shouldn't, as we save to the player map (which could be for the first time) about 25 lines below.

}
self.push_line(&format!("for _, player in {list} do"));
self.indent();
self.push_line("if player_map[player] == nil and player.Parent == nil then continue end");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use player_map for unreliables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Player is memory leaked if Fire is called after PlayerRemoving

2 participants