How to get player character before player will got remove


How i can get player character in event PlayerRemoving?

I have tried to get humanoid on character, but when I try to use it
there is an error at humanoid doesn’t exists

then how do I get player character before player will actually got remove?

Thanks and sorry for bad english.

1 Like


Uhh, when i try to use it there are error at Humanoid doesn’t exists.

You don’t. The character is gone if they’re leaving.


Then how i can get character before it gone?

You can’t predict if the player is going to leave soon. What are you trying to do? What’s your usecase?

   local Character = Player.Character
   if Character then
      local Humanoid = Character:FindFirstChild('Humanoid')
      if Humanoid then
1 Like

I’m trying to do a combat system

I trying to find ObjectValue on humanoid

That is false, I tested this.

What do you mean?

The code I provided should be your solution.

I ran that code (in Studio) and it didn’t print a thing because the Character is gone when they’re leaving.


Works fine in studio, perhaps this is a bug.

When player is leaving

Player.Character is already gone

this is error i got

21:07:52.859 - ServerScriptService.Script:123: attempt to index nil with ‘Humanoid’

1 Like

In that case, store the player in a table so you can access the instance when they’re leaving.

but we can’t know when player’ll leaving…

Use the event, then access the table.

How ? I don’t understand?

I understand as
store character everytime it added

we can’t because we don’t know when objectvalue will got added.

You can detect this by using __newindex, which is requiring a metatable.

Uhh, sorry i didn’t learning about it yet.