Will using PromptPurchase work?

I am very confused about this,
Is using this script to create ‘‘UGC’’ events a good thing?
I don’t know where to start how to make a free ugc script,

I only have this script to create, Free UGC Event
Script Code:

local UGCID = 000001
local player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local leaderstats = player:FindFirstChild("leaderstats")
	if leaderstats then
		local Level = leaderstats:FindFirstChild("Level")
		if Level and Level.Value > 1 then
		game:GetService("MarketplaceService"):PromptPurchase(player, UGCID)
		end
	end
end)

will that script work, for UGC event in my game???

2 Likes

Probably yes, i’ve never worked with limited UGCs, but i believe it will work.

2 Likes

What the Script is doing is that it’s basically checking that when the Parent of it has been clicked (this could be a GUI or anything that has a button). When it senses that it’s been checked, it will find the leaderstats folder inside the player (Keep in mind that this is not a player model inside workspace). It then looks for a value called “Level” inside the leaderstats. If the value of level is more than 1, it will prompt a purchase to that player with the UGC in it.

2 Likes

hmmm I see, I really doubt that

1 Like

so i have to re-create the script and not use LocalScript?

1 Like

You have to use a localscript because of the local player = game:GetService("Players").LocalPlayer

2 Likes

The script seems alright, juat make sure the placeholder ID is changed :D.

2 Likes

he’s right, localPlayer is local Script accessible only

2 Likes

okay thanks for your answers @ScriptedPi @yesssssssss90900

Anytime, but make sure you mark any of our answers as “Solution” if we solved your problem!

1 Like

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