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

Script not showing button when player owns gamepass?

I am trying to get a button to show if a player has the gamepass but it's not working.

local id = 1308026475

game.Players.PlayerAdded:connect(function(player)
	if game:GetService("GamePassService"):PlayerHasPass(player, id) then
	script.Parent.Visible = true
	end
end)

Please help! Thanks in advance.

2 comments

1

This is in a server script, right?

0

No it's a local script.

2 answers

Use a script instead of a localscript if your using a local script.

Make sure it's in a server script like FireyMcBlox said. If it is, I suggest adding to the script a bit.

local id = 1308026475

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
   	 script.Parent.Visible = true
else
	script.Parent.Visible = false
    end
end)

8 comments

0

The button is still not showing.

0

Does it say anything in the output?

0

Okay, so I looked up your gamepass and it's most likely because it isn't for sale.

0

No

0

I tried using another id from a gamepass that is on sale, because the one I originally wanted to use is not complete yet, but the button still isn't showing.

0

Have you converted it to the server script yet?

0

Yes. I got it to work by rewriting the whole thing but thanks anyways!

0

Mhm...

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