Is it possible to check if a player has already played another game?

I’m trying to check if a player has played another game. Not my own game though, but someone else’s.
Is this even possible?

not possible sorry. ALTHOUGH if the game has a welcome badge you could check if the player has that like this

local badge_service = game:GetService("BadgeService")
local badge_id = 0000 -- change to welcome badge id

game.Players.PlayerAdded:Connect(function(plr)
	if badge_service:UserHasBadgeAsync(plr.UserId, badge_id) then
		print('user has played other game')
		-- code here
	else
		print('user has NOT played other game')
		-- code here
	end
end)
6 Likes

That’s quite clever! I’ll check if it works right away.

yeah just keep in mind the other game has to have a welcome badge for it to work. Otherwise you’re out of luck.

Clever solution!

One is not fully out of luck though, if the game has any badges or products it’s possible to check for those. This will, of course, not be as effective as checking for a Welcome badge everyone gets.

Also, @ElVaranCubico_YT, keep in mind Users can delete badges. Most don’t do this though, so @TheH0meLands should work almost all of the time.

what do you mean by “check if player has any badges or products”?

There’s no way to have a 100% full proof method for checking this. The best choice for this is to check if the player has a welcome badge. Checking products and badges wont be as effective. I recommend you go with my method and mark it as the solution. That way if someone stumbles upon this thread they’ll find the best way to check this info.

But if you must know you can do this to check if a player owns a gamepass/product

local MPS = game:GetService("MarketplaceService")
local id = 0000 -- change to gamepass id

game.Players.PlayerAdded:Connect(function(plr)
	if MPS:UserOwnsGamePassAsync(plr.UserId, id) then
		print('user has played other game')
		-- code here
	else
		print('user has NOT played other game')
		-- code here
	end
end)

The idea is that you’d check if the player owns any of the gamepasses/has any of the badges in the other game (indicating that they have played it before).

local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local userOwnsGamePass = marketplace.UserOwnsGamePassAsync
local badges = game:GetService("BadgeService")
local userHasBadge = badges.UserHasBadgeAsync

local gamePassesIds = {1, 2, 3} --Put the other game's gamepass IDs here.
local badgeIds = {1, 2, 3} --Put the other game's badge IDs here.

local function hasPlayerPlayedGame(player)
	for _, gamePassId in ipairs(gamePassesIds) do
		local success, result = pcall(userOwnsGamePass, marketplace, player.UserId, gamePassId)
		if success then
			if result then
				return true
			end
		else
			warn(result)
		end
	end
	
	for _, badgeId in ipairs(badgeIds) do
		local success, result = pcall(userHasBadge, badges, player.UserId, badgeId)
		if success then
			if result then
				return true
			end
		else
			warn(result)
		end
	end
	return false
end

local function onPlayerAdded(player)
	local hasPlayedGame = hasPlayerPlayedGame(player)
	if hasPlayedGame then
		print(player.Name.." has played the other game!")
	else
		print(player.Name.." has not played the other game!")
	end
end

players.PlayerAdded:Connect(onPlayerAdded)
2 Likes