I need to run a function on the Character when the player decides to leave. CharacterRemoving also launches when the character is respawning, I only need it when the player is leaving. I can’t use PlayerRemoving, because the character is destroyed before the PlayerRemoving function is ran. Any idea to run a function on the character when the player decides to leave?
--This is what I tried to do but it runs when the player respawns (Yes, ive read the API). the event was inside the PlayerAdded event
--[[plr.CharacterRemoving:Connect(function(character)
if character then
SpawnBackpack(plr:FindFirstChild("Inventory"), plr, character)
print(character)
end
end)]]
end)--PlayerAdded event end
game:GetService("Players").PlayerRemoving:Connect(function(plr)
local profile = ProfileManagerModule.Profiles[plr]
if not profile then return end
profile:Release()
end)