I have the following script:
game.Players.PlayerRemoving:Connect(function(plr)
local char = plr.Character
local stats = plr.hidden
local stat = stats.follow
if char:FindFirstChild('Doge') then
local boost = char.Doge.Boost
stat.Value = stat.Value - boost.Value
print('success!')
end
end)
It doesn't work because the players character is gone when the function is fired. Is there any other way to do this?

1 comment
You could try using the CharacterRemoving event on the player, as the event fires right before the character is removed: https://developer.roblox.com/api-reference/event/Player/CharacterRemoving