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

Why won't this gamepass show the GUI when I go test it out?

Asked by 5 years ago
local id = 6625946

game:GetService("MarketplaceService"):PromptGamePassPurchaseFinished:Connect(function,ido,purchase)
    if purchase and ido == id then
        game.StarterGui.TestGui.TextButton.Visible = true
end)

game.Players.PlayerAdded:Connect(function(plr)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id)then
        game.StarterGui.TestGui.TextButton.Visible = true
    end
end)

2 answers

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago

StarterGui is a service that clones anything into it into the "PlayerGui" of a player. Instead, we'll make the script a client side script in the GUI itself.

local id = 6625946

local Player = game:GetService("Players").LocalPlayer
local MarketPlaceService = game:GetService("MarketplaceService")

local UserOwnsPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId,id)

if UserOwnsPass then
    print("Success!")
    script.Parent.TextButton.Visible = true
end
0
Thank you! Luke2323244 17 — 5y
Ad
Log in to vote
0
Answered by
JakyeRU 637 Moderation Voter
5 years ago

Hello.

You are changing the TextButton Visible property on the server. (game.StarterGui.TestGui.TextButton).

To make it work, you have to change it in the PlayerGui. For example:

game.Players.PlayerAdded:Connect(function(player)
    if yourcondition then
        player:WaitForChild("PlayerGui").TestGui.TextButton.Visible = true
    end
end)
0
Thanks, I've done what you have told and some reason it not work but it has a red line one line 3 where it say "PromptGamePassPurchaseFinished:Connect" the red line is under the colon. Luke2323244 17 — 5y

Answer this question