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"?
The following code should work:
01 | local market = game:GetService( "MarketplaceService" ) |
02 | local g = script.Parent |
03 | local player = game.Players.LocalPlayer |
04 |
05 | local assetId = 00000 |
06 |
07 | -- insert event that triggers 'market:PromptPurchase(player,assetId)' |
08 | -- e.g 'script.Parent.MouseButton1Down:connect(function()' |
09 |
10 | while true do |
11 | local check = market:PlayerOwnsAsset(player,assetId) |
12 | if check and g.Visible = = false then |
13 | g.Visible = true |
14 | end |
15 | wait( 1 ) |
16 | 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