Any way to make a frame visible if player have a gamepass?

Hi! So i tried to make a frame get visible if player owns a gamepass, and the script isnt working ):
Heres my script:

local gamepassID = 12524399
local MarketplaceService = game:GetService("MarketPlaceService")


game.Players.PlayerAdded:Connect(function(player)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID) then 
		script.Parent.Visible = true
	end
end)

Hey :slight_smile:

Is that a local script?

PlayerAdded works only on server

1 Like

o yea its an localscript- but if i do on server doesnt it make visible for all players?

local gamepassID = 12524399
local MarketplaceService = game:GetService("MarketPlaceService")


game.Players.PlayerAdded:Connect(function(player)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID) then 
		--to clone a UI
		local UI = script.ScreenGui:clone()
		UI.Parent = player.PlayerGui
		UI.Frame.Visible = true
		--to visible an exisiting UI
		local GUI = player.PlayerGui["YOUR_GUI"]
		if GUI then
			local frame = GUI["FRAME"]
			if frame then
				frame.Visible = true
			end
		end
	end
end)
1 Like

if you wanted to make it on client -

local gamepassID = 12524399
local MPS = game:GetService("MarketPlaceService")
local Player = game:GetService("Players").LocalPlayer


repeat task.wait() until Player.Character

if MPS:UserOwnsGamePassAsnyc(Player.UserId,gamepassID) then
	--Make UI's frame visible
end
1 Like

thank you soso much!! that was the final step of my UI<3