Help prompting a UGC Limited

Hi, developers!

I’m working on making a UGC game for players to try and obtain a free UGC limited. My problem arises when I attempt to prompt the item. I currently am using a remote event (as I see most games do), but I get an error when it actually fires:

image

Here’s some context:
image
image

It’s using the player that joined to fire it, but even if I change I make it so the player parameter in the client event function is, in fact, a player object, it’ll still error.

Tons of players are anticipating the item to be out soon, and I thought the devforum would be a great place to resort to after all the failed attempts. Any help would be HUGELY appreciated, considering I have NO experience prompting free UGC limiteds :sob:.

Thank you!!

2 Likes

Why do you need a RemoteEvent in this situation? If your goal is to prompt the player with the UGC when they join. You can simply do:

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

local UGC_ID = 0 -- // Replace with your item id

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait() -- // Wait until the player is actually loaded in.
	MarketplaceService:PromptPurchase(plr, UGC_ID)
end)
1 Like

its designed to trigger if they get a certain chance. sorry i didnt clarify that earlier

1 Like

How often do they have a chance at getting it, or does it run when they join?

1 Like

its somewhat common. the chance actually starts to tick every second when they join the game

1 Like

So does the player have a chance every second themselves? Or is it a server-wide tick where once it happens, it chooses a player to give it to?

1 Like

its every second for their player only (at least it should be)

1 Like
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

local UGC_ID = 0 -- // Replace with your item id
local Chance = 10 -- //  Edit this to your liking, this represented 1 in x. (In this case it's 1 in 10)

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait() -- // Wait until the player is actually loaded in
	
	while true do
		task.wait(1)
		if not Players:FindFirstChild(plr.Name) then
			break -- // Prevents the while loop from running once they've left.
		end
		
		if math.random(1, Chance) == 1 then
			MarketplaceService:PromptPurchase(plr, UGC_ID)
			break -- // Ends the while loop once they've won.
		end
	end
end)