Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can't get the frame to disappear for people who don't own the gamepass?

local MarketplaceService = game:GetService("MarketplaceService")
 
local Players = game:GetService("Players")
 
local passId = 4764164
 
local function onPlayerAdded(player)
 
    local hasPass = false
 
    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)
 
    if hasPass == true then
 
        game.StarterGui.guimobile.Omnitrix.Frame.Visible = true

	if hasPass == false then
		
		game.StarterGui.guimobile.Omnitrix.Frame.Visible = false
		
	end

    end
 
end
 
Players.PlayerAdded:Connect(onPlayerAdded)
  

I'm a beginner at scripting so I don't know much about why it's wrong.

1 answer

On line 17: change if to elseif and delete the end on line 21. Also on line 15 and 19: change game.StarterGui to: player:WaitForChild("PlayerGui") (it may not work though) Code:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local passId = 4764164
local function onPlayerAdded(player)
	local hasPass = false
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)
	if hasPass == true then
		game.StarterGui.guimobile.Omnitrix.Frame.Visible = true
	elseif hasPass == false then
		game.StarterGui.guimobile.Omnitrix.Frame.Visible = false
	end
end
Players.PlayerAdded:Connect(onPlayerAdded)

2 comments

1

Could you change the script for me and put it in a code block? I did it myself and it didn't work, sorry for asking so much

0

Okay.

This discussion is preserved as it was. New answers, comments, and votes are closed.