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:
Here’s some context:
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 .
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)
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)