How to find value in character after they died?

function onCharacterDied(character)

end

function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	if humanoid then
		humanoid.Died:Connect(function()
			onCharacterDied(character)
		end)
	end
end

function onPlayerAdded(player)
	if player then
		player.CharacterAdded:Connect(onCharacterAdded)
	end
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

When the character dies they have a IntValue in them, how do I access it when they die I tried defining a variable but it didn’t exist because the character model got destroyed

EDIT: nvm for some reason it didn’t work before but I did the same thing and it worked, idk if roblox was trolling me like they usually seem to do but all I did was add local int = findfirstchild(the int value in character)

3 Likes

You could put the value in the player in game.Players then just use

game.Players[character.Name][ValueName].Value