Item Catalog Purchase Prompt And Kick Script Not Working For Unknown Reason

The server sided script not only isn’t sending the purchase prompt but it’s not kicking the player, I want to make this script so it detects an item and if you have it, it prompts a purchase without having to press a button and if you do not own that item it kicks you from the game, Currently I’ve tried looking online and changing a couple things, the only way I can prompt a purchase is by putting the prompt in a .MouseButton1Click function and the kick player script isn’t even working.

Code:

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ITEM_ID = 2598774005


local ASSET_ID = 9255011
local ASSET_NAME = "Silverthorn Antlers"

local function onPlayerAdded(player)
	local _success, doesPlayerOwnAsset = pcall(MarketplaceService.PlayerOwnsAsset, MarketplaceService, player, ASSET_ID)
	if doesPlayerOwnAsset then
		print(player.Name .. " owns " .. ASSET_NAME)
		game.StarterGui.ScreenGui.Enabled = true
		
		print("gate")
		wait(2)
		game.Players.PlayerAdded:Connect(function(plr)
			MarketplaceService:PromptPurchase(plr, ITEM_ID)
		end)
		print("gate")
	else
		wait(1)
		print("gate")
		Players.PlayerAdded:Connect(function(Player)
			Player:Kick("Lol")
		end)
		print(player.Name .. " doesn't own " .. ASSET_NAME)
		game.StarterGui.ScreenGui.Enabled = false
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)

any help would be appreciated. Thanks.

1 Like

why are you using PlayerAdded inside a PlayerAdded??? you already have the player argument…

2 Likes

remove them and your code should we working.

Thanks man, I can’t believe I missed something that simple :joy:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.