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

UserOwnsGamePassAsync not working for GUI?

Here's my code:

local id = 5885163
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 5885163) then
    script.Parent.Visible = true
else
    script.Parent.Visible = false
end

No error statements. I've been at this for a week now and can't figure it out. Nothing seems to work. It's inside a local script in the textbutton. The Frame is named "Skins" and the button is named "SkinsButton", if that helps. The GUI is names "SkinsGUI". Any ideas?

2 comments

0

It’s .UserId, you also gave the Gamepass’s ID in a variable, so why didn’t you give it that for the second argument?

0

That ID provided is not a game pass.

1 answer

✓ Accepted answer
local id = 5885163
local player = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
	    script.Parent.Visible = true
	else
	    script.Parent.Visible = false
	end
end)

A. You defined the id, so you can just replace the number in the GamePassAsync with its variable

B. The property name of player.userId is invalid, it must be capitalized to player.UserId

C. Make sure that you an "end)" at the end of the function

D. Use Activated instead of MouseButton1Click since Activated works for all devices while MouseButton1Click only works for computers.

4 comments

0

Does this only function on ServerSide or will it function on PlayTest in studio or both? Doesn't function on my PlayTest.

0

PlayTest is now able to work the same way that a normal server would, so whatever you see there is the same as in-game. This wouldn't work on the Server since the script should be a local script

0

It is, and doesn't work.

0

remove the lines: "script.Parent.Activated:Connect(function()" and "end)" and try

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