From e4ed09f3a632037052afb73c735267e20307ea1b Mon Sep 17 00:00:00 2001 From: Magic <64741104+Mark-Marks@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:53:24 +0200 Subject: [PATCH] fix: Per player channel doesn't exist when sending data When trying to fire an event on `PlayerAdded`, the channel for the player isn't created yet and the code errors. This is due to the lack(?) of ordering for `PlayerAdded`. --- src/process/server.luau | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/process/server.luau b/src/process/server.luau index fcac755..4b4e7ac 100644 --- a/src/process/server.luau +++ b/src/process/server.luau @@ -73,6 +73,9 @@ function serverProcess.sendPlayerReliable( writer: (value: any) -> (), data: { [string]: any } ) + if not perPlayerReliable[player] then + perPlayerReliable[player] = create() + end perPlayerReliable[player] = writePacket(perPlayerReliable[player], id, writer, data) end @@ -82,6 +85,9 @@ function serverProcess.sendPlayerUnreliable( writer: (value: any) -> (), data: { [string]: any } ) + if not perPlayerUnreliable[player] then + perPlayerUnreliable[player] = create() + end perPlayerUnreliable[player] = writePacket(perPlayerUnreliable[player], id, writer, data) end