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

I need help on this script please help?

local passid = 157704756
local GamePassService = Game:GetService("GamePassService")
local character = player.Character

if GamePassService:PlayerHasPass(player, passid) then
print("Human passed test") 
else script.Parent:remove()
end 

I want to make it work if the player has the gamepass , the gui will show to them. if they dont have the gamepass then it won't show. please help me i need it!

3 answers

✓ Accepted answer
local passid = 157704756
local GamePassService = Game:GetService("GamePassService")
local character = player.Character
local player = game.Players.LocalPlayer -- forgot to say who the player is.

if GamePassService:PlayerHasPass(player, passid) then
print("Human passed test") 
else script.Parent:Remove() -- Forgot to Cap the R in remove.
end 

I believe this should work. If not please let me know.

First thing, is this a LocalScript?

If so, to get the local player fast:

local player = game.Players.LocalPlayer -- Your player

Then you can get your Character, etc.

local passid = 157704756
local GamePassService = Game:GetService("GamePassService")
local player = local player
local character = player.Character
 
if GamePassService:PlayerHasPass(player, passid) then
print("Human passed test")
else script.Parent:remove()
end

You forgot to define player.

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