Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by
X_Z 0
2 years ago

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
Ad

Answer this question