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

How would I go about allowing access to GUI if they are either on the list or have the gamepass?

Greetings!

I seem to never escape Lua's many confusions, as it's still a steep learning curve for me (but I still hope to really learn it thoroughly and create some great games with my friend), but something new's creeped up on me.

Recently, we had some contributors help with models for this game, and my friend instructed me to script it so that they can access a VIP GUI without having to purchase the pass, as a thank you to them.

So, me, thinking that it's simple, write this (as an example):

local player = game.Players.LocalPlayer
local vipframe = script.Parent.Parent.VIPFrame

function onClick()
	if player.Name == "Jeff" or player.Name == "Bob" or player.Name == "Jeb" then
		print('Player is on list.')
		vipframe.Visible = true
	end
	if game.Workspace.VIPGamepass:InvokeServer(12345678) then
		print('Player has pass.')
		vipframe.Visible = true
		else
			print('Player doesn't have game pass.')
			game:GetService("MarketplaceService"):PromptPurchase(player,12345678)
		end
	end

The button works if say my name is on the list, as in the console it shows 'Player is on list', however when I remove my name to check for the pass... nothing. It doesn't invoke and check if I have the pass, nor displays the VIP GUI, nor prompt me to purchase. I am quite confused, and I have a suspicion that it has to do with my use of if statements, but I am otherwise lost. Any clues?

2 comments

0

You never closed the print that says they don't have the pass, properly.

0

Simple typo, thanks for pointing it out, but still.

1 answer

✓ Accepted answer

Try this, I used a different ROBLOX function to check if they own the pass.

local player = game.Players.LocalPlayer
local vipframe = script.Parent.Parent.VIPFrame

function onClick()
    if player.Name == "Jeff" or player.Name == "Bob" or player.Name == "Jeb" then
        print('Player is on list.')
        vipframe.Visible = true
    end
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userid,12345678) then
        print('Player has pass.')
        vipframe.Visible = true
        else
            print("Player doesn't have game pass.")
            game:GetService("MarketplaceService"):PromptPurchase(player,12345678)
        end
    end

1 comment

0

Thank you good sir! It worked! I'm not sure why I was using what I was using before.. maybe I should read up more. But thanks again!

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