use

while not NetworkIsPlayerActive(PlayerId()) do
Wait(100)
end

you are using if statement
the script is loaded first before the player active bool