Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

0
^ still a nub to covering links too. SoftlockedUnderZero 668 — 5y
0
I think your code works, however it did not fix the problem :( lilydog07 0 — 5y
0
Yea i see, i will re edit SoftlockedUnderZero 668 — 5y
0
Also dont use shirts as gamepasses tho SoftlockedUnderZero 668 — 5y
Ad
Log in to vote
0
Answered by 4 years ago

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!

Answer this question