How to check player owns asset if the player isn't in the game?

I’m trying to make a simple whitelsit script that checks if the game owner owns the asset and have access to the in game vehicle. For example, if the creator owns car1 shirt, the car1 in game will allow to use, if not, it will remove. The problem is the script can’t get the player or creator if he isn’t in the game and I don’t know how to script to get player from outside.

Here’s my simple whitelist script :

wait(0.25)
local owner
if game.CreatorType == Enum.CreatorType.User then
	owner = game.CreatorId
else
	owner = game:GetService("GroupService"):GetGroupInfoAsync(game.CreatorId).Owner.Name
end
if game:GetService("MarketplaceService"):PlayerOwnsAsset(owner,4951402028) then
	print("Owner has the truck yey")
else
	script.Parent:Destroy()
end
1 Like

You can just make a local script to check if the owner does not own the asset. and keep checking it, because if the owner buys the asset while in-game, then it will change.
Example:
Server Script:, I have made a remote event called CheckTruck

game.Players.PlayerAdded:Connect(function(plr)
	if(game.CreatorType == Enum.CreatorType.Group) then
		game.ReplicatedStorage.CheckTruck:FireClient(game:GetService("GroupService"):GetGroupInfoAsync(game.CreatorId).Owner.UserId)
	else
		game.ReplicatedStorage.CheckTruck:FireClient(plr, game.CreatorId)
	end
end)

And the local script inside of the starter player

local player = game.Players.LocalPlayer
local owner
game.ReplicatedStorage.CheckTruck.OnClientEvent:Connect(function(creatorId)
	if game.CreatorType == Enum.CreatorType.User then
		print(player.UserId)
		owner = creatorId --I assume that this is the player Id
		print(owner)
		if(player.UserId == owner) then
			print("yej")
			if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 4951402028) then
				--For example, set the truck's parent to the workspace
	                          print("Owner has truck yey")
			end
		end
	else
		owner = creatorId
		if(player.UserId == owner) then
			if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 4951402028) then
				--For example, set the truck's parent to the workspace
	                          print("Owner has truck yey")
			end
		end
	end
	while wait(1) do
		if game.CreatorType == Enum.CreatorType.User then
			owner = creatorId --I assume that this is the player Id
			if(player.UserId == owner) then
				if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 4951402028) then
					--For example, set the truck's parent to the workspace
	                                 print("Owner has truck yey")
				end
			end
		else
			owner = creatorId
			if(player.UserId == owner) then
				if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 4951402028) then
					--For example, set the truck's parent to the workspace
	                                 print("Owner has truck yey")
				end
			end
		end
	end
end)

I have also fired the group id, so incase it is 0, because it is a local script, it won’t be 0, it will be the actual one.
Another edit:
Works for me
image

1 Like

Hmmm I just want it like checks the game creator’s owned assets. Like when other people join his game and spawn the car, if the creator doesn’t own a car shirt from original car creator, all of them in game won’t be able to use it. Game creator must buy a shirt to have access to use in game, and I don’t want the script check only in-game players because it needs creator to join to make the whitelist works. Only thing I want to solve is how to get game creator user or other users from outside. And this is similar to the admin command when you want to run :ins command, the system will check the game creator’s asset and spawn it into the game.

So you want to check if other game creators have the shirt? and if they do, they can spawn a car?

Yes, without needing the creator to play the game.

Hmmm, I don’t think it is possible that every game creator will be able to get checked, but if you have specific game creators, then you can create a white list by their ids, and if the specific players with the specific ids have the shirt, then they own the car.

1 Like

Ok I’ll try, thanks for the help anyways.

1 Like

No problem, just put the ids in my local script, and there’s no need now for the remote event, you can just do if player.UserId == OwnerUserId or player.UserId == OtherOwnerUserId. then you don’t even need the owner veriable, because that is the player. and instead of directly spawning the car, you can add a gui to be enabled, that he can spawn the car from there.

1 Like

I’m actually looking for something like that. Unfortunately, I believe the Roblox Api does not have a function to check if a player owns an asset while they’re not in game. (If I’m wrong, correct me please)

I tried to find a solution, but it did not work. It was to use the invetory API that’s going to return all the owners of an asset. What I tried to do is go through them, and see if the player (that’s not in game) appears in that list. The reason it didn’t work is because for some reasons, Roblox doesn’t allow you to make Http requests to their own website.

Actually , you technically could make it work, by requesting a website to request the Roblox website, to basically return the list of owners. Although, there are many ways to do that, and it would take a bunch of time for me to explain everything. Just leaving the used URL in case anyone is interested.

https://inventory.roblox.com/v2/assets/4951402028/owners?sortOrder=Asc&limit=100

5 Likes