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’
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.
Or should i will store character that will got removing on ServerStorage
Maybe you can look into player.CharacterRemoving instead.
If you want to get the player’s character couldn’t you use the CharacterRemoving event rather than the PlayerRemoving event?
Just like what Syclya said ^
Why would you want to get the character right before the player gets removed rather than right before when the character gets removed?
by doing this maybe i would do like that
--- example char removing evnet
if game.ServerStorage.Backup:FindFirstChild(char.Name) then
game.ServerStorage.Backup:FindFirstChild(char.Name):Destroy()
end
char:Clone().Parent = game.ServerStorage.Backup
end
i want to get it because im doing combat log system, if player on combat will do something.
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(Player)
Player.CharacterRemoving:Connect(function(Character)
local Check = Players:GetPlayerFromCharacter(Character)
if not Check then
-- they are no longer in game.
end
end)
end)
Perhaps something like this (?)