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

why am i getting this error :game pass can only be queried in roblox game servers?

this is my local script on a button in starter ui

local GamePassService = game:GetService('GamePassService')
	local CatGamepass = 26348478
	local Player = game.Players.LocalPlayer
	 
	script.Parent.MouseButton1Click:Connect(function()
	if GamePassService:PlayerHasPass(Player, 26348478) then            
		Player.leaderstats.FaceValue.Value = "Uwu"
		Player.leaderstats.Hat.Value = "Uwu"

	else print("error")
		
		
	end
	 
end)

1 answer

The :PlayerHasPass() method can only be used on the server and not in a local script/ the client. If you want to check from the client, I would do a RemoteFunction that returns the result of the method back to the client.

Here's an example with a RemoteFunction in the replicated storage.

Server script

local RemoteFunction = game.ReplicatedStorage:WaitForChild("Remote")
local GamePassService = game:GetService('GamePassService')

RemoteFunction.OnServerInvoker = function(Player, GamePassId)
	return GamePassService:PlayerHasPass(Player, GamePassId)
end)

LocalScript

local RemoteFunction = game.ReplicatedStorage:WaitForChild("Remote")

local HasPass = RemoteFunction:InvokeServer(26348478)  --This will be true or false

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