From d74df0ac3428f42c2e7ef6652cbbe8a1d65f6d7a Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:16:33 +0300 Subject: [PATCH] Fix NULL error --- lua/webaudio/receiver.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/webaudio/receiver.lua b/lua/webaudio/receiver.lua index 826eaa0..f40bb25 100644 --- a/lua/webaudio/receiver.lua +++ b/lua/webaudio/receiver.lua @@ -329,13 +329,16 @@ function updateObject(id, modify_enum, handle_bass, inside_net) self.parented = net.ReadBool() if self.parented then local ent = net.ReadEntity() - self.parent = ent - if self.pos ~= nil then - -- We've initialized and received a changed position before - self.parent_pos = ent:WorldToLocal(self.pos) - else - -- self.pos hasn't been touched, play the sound at the entity's position. - self.parent_pos = nil + + if IsValid(ent) then + self.parent = ent + if self.pos ~= nil then + -- We've initialized and received a changed position before + self.parent_pos = ent:WorldToLocal(self.pos) + else + -- self.pos hasn't been touched, play the sound at the entity's position. + self.parent_pos = nil + end end else self.parent = nil