Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making a script that allows a player to view a gui after buying a free decal or model?

So, I am making a gui menu of different missions. How would you write a script that allows a player to view a gui (ie. make it visible) upon purchasing a free decal or model? The reason I'm not using GamePass is that it's not "free", and I'm using the TeleportService script to teleport players into the missions, so having a "Touched" brick function wouldn't work (if so, how would I do so).

Can I use the "GamePassService", or do I have to use the "MarketplaceService"?

1 comment

0

Marketplace service will work just fine, just make sure it's in a normal script and just wait for the receipt

2 answers

✓ Accepted answer

The following code should work:

local market = game:GetService("MarketplaceService")
local g = script.Parent
local player = game.Players.LocalPlayer

local assetId = 00000

-- insert event that triggers 'market:PromptPurchase(player,assetId)'
-- e.g 'script.Parent.MouseButton1Down:connect(function()'

while true do
	local check = market:PlayerOwnsAsset(player,assetId)
	if check and g.Visible == false then
		g.Visible = true
	end
	wait(1)
end

Note: To find the LocalPlayer instead of using script.Parent.Parent etc., this script needs to be a LocalScript

For more info on MarketplaceService etc.: http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService

This discussion is preserved as it was. New answers, comments, and votes are closed.