so i wanna detect if player leave using local script but the only issue is the variable become 1 upper after i declarate if
statement
this is the code
local billboard = game.ReplicatedStorage.BillboardGui
player.CharacterAdded:Connect(function(character)
local billboardclone = billboard:Clone()
billboardclone.Parent = character:WaitForChild("Head")
end)
game.Players.PlayerRemoving:Connect(function(playerleave)
if player == playerleave then
print(player.Character)
print(player.LocalPlayer.Character)
end
end)
output:
15:42:52.881 RahmatHidayat2154 - Client - handler:11
15:42:52.883 LocalPlayer is not a valid member of Player "Players.RahmatHidayat2154" - Client - handler:12
15:42:52.883 Stack Begin - Studio
15:42:52.883 Script 'Players.RahmatHidayat2154.PlayerScripts.handler', Line 12 - Studio - handler:12
15:42:52.884 Stack End