So I am new at lua and was figuring out how to make a gui for gamepass owners only. This is my script, no errors but it's not working (note that it was a studio test.)
wait(1) gamepassid = 7106056 MPS = game:GetService("MarketplaceService") function respawned(char) local player = game.Players:FindFirstChild(char.Name) if char:FindFirstChild("Head") ~= nil then if MPS:UserOwnsGamePassAsync(player.UserId, gamepassid) then print"Player has Gamepass" script.Parent.Visible = true end else print"Player does not have gamepass." end end game.Workspace.ChildAdded:connect(respawned)
And it's annoying because the title made me do stuff and I didn't want to type the actual meaning of GUI.
So, you should use Local Script inside GUI's, first of all, the best way is to use Local Player since it's the Local Script so you can get Local Player from Players service.
local GamepassID = 7106056-- ID of your gamepass local Player = game:GetService("Players").LocalPlayer local MarketplaceService = game:GetService("MarketplaceService") game.Players.PlayerAdded:Connect(function() -- Runs a function when player joined. if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then -- Checks if player has the gamepass print("Player owns a gamepass!") script.Parent.Visible = true else print("Player doesn't have the Gamepass") end end)