Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
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 gam2010 9 — 5y
0
Okay. User#22219 20 — 5y
Ad

Answer this question