Gamepass Owner Only Gui?

local PassId = 39937164
game.Players.PlayerAdded:connect(function(p)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.UserId, PassId) then
		p.PlayerGui.TeamChange.Main.AvailableTeams.Visible = true
	end
	p.CharacterAdded:Connect(function()
		p.PlayerGui:WaitForChild("TeamChange"):WaitForChild("Main"):WaitForChild("AvailablrTeams").Visible = true
	end)
end)

How would I make this work? This is a serverscript in SSS.

2 Likes

wait i dont understand you want a gamepass that you can buy but its only for the owner???
btw please for the love of god create variables for services

local PassId = 39937164
local mpService = game:GetService("MarketplaceService")
local plrService = game:GetService("Players")

plrService.PlayerAdded:connect(function(p)
	if mpService:UserOwnsGamePassAsync(p.UserId, PassId) then
		p.PlayerGui.TeamChange.Main.AvailableTeams.Visible = true
	end
	p.CharacterAdded:Connect(function()
		p.PlayerGui:WaitForChild("TeamChange"):WaitForChild("Main"):WaitForChild("AvailablrTeams").Visible = true
	end)
end)
2 Likes

Can you tell me whats wrong about it? I cannot tell, can’t run it so can’t get the error myself

1 Like

No. I meant if you own the gamepass you can SEE the gui.

It doesn’t work at all. Doesn’t do anything.

is it a localscript by any chance…
because i have no idea why it wouldnt work otherwise
did you misspell this
image

2 Likes

oh, my bad. Oops, mispelled it. lemme try (still doesnt work)

1 Like

check output maybe

1 Like

After the marketplaceservice try adding a == true but not sure, then you probably should add onto the gui the property resetonspawn or something like that as that clears all guis that don’t have it

1 Like

also wait are you changing the same frame to visible in the characted added function and userownsgamepass check

1 Like

Trying actually waiting for the gui loads as soon as the player joins…

local PassId = 39937164
local mpService = game:GetService("MarketplaceService")
local plrService = game:GetService("Players")

plrService.PlayerAdded:connect(function(p)
	if mpService:UserOwnsGamePassAsync(p.UserId, PassId) then
		p:WaitForChild("PlayerGui"):WaitForChild("TeamChange"):WaitForChild("Main"):WaitForChild("AvailableTeams").Visible = true
	end
	p.CharacterAdded:Connect(function()
		p.PlayerGui:WaitForChild("TeamChange"):WaitForChild("Main"):WaitForChild("AvailableTeams").Visible = true
	end)
end)