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

How do I enable a certain GUI if the player has a game pass?

Hi, I'm trying to make a gui only appear to that player if they own a game pass. Here is the script I tried using, but it didn't work:

local PassId = 11379241
game.Players.PlayerAdded:connect(function(p)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.UserId, PassId) then
		p.PlayerGui.speed.Frame.Visible = true
	end
	p.CharacterAdded:Connect(function()
		p.PlayerGui:WaitForChild("speed"):WaitForChild("Frame").Visible = true
	end)
end)

If you see anything wrong please let me know, thanks.

1 comment

0

Will write some code for this in a second hold on

2 answers

✓ Accepted answer
	local PassId = 11379241
	game.Players.PlayerAdded:connect(function(p)
	    p.CharacterAdded:Connect(function()
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.UserId, 					PassId) then
		p.PlayerGui.speed.Frame.Visible = true
	    end)    
	end)

1 comment

0

Thanks.

I would recommend using Remote Functions to utilities this.

-- Server Code

local YourEVENT = something

local PassId = 000000

YourEVENT.OnServerInvoke = function(plr)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, PassId) then
		return true
	else
		return false
	end
end

-- Client

local YourEVENT = blah blah blah

if YourEVENT.InvokeServer(plr) then
	print('Player Has Pass')
       -- Make the Gui visible here
else
	print('Player does not have pass') 
       -- Don't do anything or make it not visible to double check
end

1 comment

0

Oops i just realized he answered this! My bad!

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