game.Players.PlayerRemoving:connect(function(player)
	coroutine.resume(coroutine.create(function()
		local plrKills = ods:GetAsync(tostring(player.userId).."Kills")
		local plrXp = ods:GetAsync(tostring(player.userId).."XP")
		if not plrKills then plrKills = 0 end
		if not plrXp then plrXp = 0 end
		for i = 1,#currentData do
			if currentData[i][1] == player.Name then
				ods:SetAsync(tostring(player.userId).."Kills",plrKills + currentData[i][3])
				ods:SetAsync(tostring(player.userId).."XP",plrKills + currentData[i][2])
			end
		end
	end))
end)

This isn't firing when the player leaves. Could this be due to filtering enabled? If so, how do I fix?

2 comments

0

Is it a local or regular script? Also, the key for a datastore cannot be the userId alone, so try doing something like: "user_"..player.userId instead of tostring(player.userId).

0

It's in a regular script. And it's player.userId.."KILLS"