I recently just made this script that moves a gui to a player's playergui if they have a gamepass, and if not it moves a "Fake" version to fill the spot up.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 5068130  -- Change this to your game pass ID 
 
function onPlayerSpawned(player) 
    
    local hasPass = false
 
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
  print("Has Game Pass for OVO")
    end)
  
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end
 
    if hasPass == true then
  game.Lighting.FastTravel:clone().Parent = player.PlayerGUI else
  game.Lighting.FakeTravel:clone().Parent = player.PlayerGUI
 end
end 

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)


Players.PlayerSpawned:Connect(onPlayerSpawned)

For some reason when players join the game the spot where the gui would be is blank. How do I make it so this will work? I've tried events but those did not work in my favor. "FastTravel" is the Gamepass gui, "FakeTravel" is the placeholder one.

2 comments

0

ew, ur script is a free model + deprecated, you're using "Lighting" as storage, "connect" instead of "Connect", you can't access PlayerGui from server lol

0

This is from the RobloxDev.