This script makes sure only people owning a specific gamepass can see the UI, after releasing this update I noticed the ui dissapears after you die or reset. even if you own the gamepass.
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local TweenService = game:GetService("TweenService")
local GamePassID = 1023661238 -- 1023661238
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
-- Wait for the player's GUI to load
local playerGui = player:WaitForChild("PlayerGui", 10)
if not playerGui then
warn("PlayerGui not found for:", player.Name)
return
end
-- Check if the player owns the game pass
local ownsGamePass = false
local success, errorMessage = pcall(function()
ownsGamePass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamePassID)
end)
if not success then
warn("Error checking game pass ownership for", player.Name, ":", errorMessage)
return
end
-- If they own the game pass, make the GUI visible
if ownsGamePass then
local gamePassGui = playerGui:FindFirstChild("GamepassGui")
if gamePassGui then
gamePassGui.Enabled = true
print("GamepassGui enabled for:", player.Name)
else
warn("GamepassGui not found for:", player.Name)
end
else
print(player.Name .. " does NOT own the game pass.")
end
end)
end)