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

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

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

✓ Accepted answer

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

1 comment

0

Thank you!

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)

1 comment

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.

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