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

How do I make a gui show up if a player has a gamepass?

I'm working on this game and if you buy a certain gamepass a gui button will show up on the side of your screen (clicking it will result in a popup gui that allows you to choose your chat color) The only problem is I have tried, several times, to get the button to show up and it hasn't(and yes, I did also try it in a server yet it still failed). Here is what I have so far, a word of warning I am an extremely novice scripter :)

The script is under ServerScriptStorage and it reads :

local id = 6328358 game.Players.PlayerAdded:connect(function(player) if local HasPass = Game:GetService("GamePassService"):PlayerHasPass(player, id) then player.PlayerGui:WaitForChild("ColorGui").Enabled = true end end)

2 answers

I am currently a nub to answering with code blocks. Basically my version uses MarketplaceService instead of GamePassService for GamePass Ids

local MPS= game:GetService("MarketplaceService") local AssetId = 4661048 function playeradded(player) local GPCheck = MPS:UserOwnsGamePassAsync(player.UserId,AssetId) if GPCheck==true then print(player.Name .. " owns the game pass with ID " .. gamePassID) end end

4 comments

0

^ still a nub to covering links too.

0

I think your code works, however it did not fix the problem :(

0

Yea i see, i will re edit

0

Also dont use shirts as gamepasses tho

I figured it out! Here is the setup I have: A script under Server Script Service that reads
local mps = game:GetService("MarketplaceService") local gamepass = 6328358

script.ColorGui.ResetOnSpawn = false game.Players.PlayerAdded:Connect(function(player) while true do if mps:UserOwnsGamePassAsync(player.UserId,gamepass) then script.ColorGui:Clone().Parent = player.PlayerGui end wait(5) end end)

Inside it is my gui set to enabled, and I have tested it this works in studio and in game.I tested it with an alt too so only if you have the gamepass it will show up!

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