I’m using the zoneplus module right now, and when the player enters a new zone, I want the server to do a sanity check to confirm that the player is actually in that specific zone whenever the remote event is fired.
But for some reason, the server script won’t print out the message. I’ve narrowed down the problem to be because of the if statement in the server script.
if not zone:findPlayer(player) then zone:destroy() return end
Specifically, zone:findPlayer(player)
is false, even though the player has indeed entered said zone.
Local script
for _, zone_part in pairs(AncestorContainer:GetChildren()) do
local zone = Zone.new(zone_part)
zone.localPlayerEntered:Connect(function()
NPC_StateChange:FireServer(zone_part) -- player entered a zone, pass through the specific zone part the player entered
end)
end
Server script
NPC_StateChange.OnServerEvent:Connect(function(player, zone_part)
print("remote event fired") -- this does print
-- confirm fired remote event is valid by checking that player is inside the zone on server side
local zone = Zone.new(zone_part)
if not zone:findPlayer(player) then zone:destroy() return end
zone:destroy()
print("it works") -- this does not print
end)
All of this works perfectly fine when the spawn is located inside a zone but when entering a new zone, it just doesn’t recognize the player is inside another zone.
For context, this is what the zone looks like (the slightly transparent part) and the spawn is located just outside of the part.