Gamepass-only UI goes away after resetting character

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)

try to set screenGui.ResetOnSpawn to false

2 Likes

Dang I did not know that property existed, Thank you!!

1 Like

This property is set to default, just for you to know before you mess up things again :smiley:!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.