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

Why is my gamepass script not working? And why am i getting an error?

Asked by
sad_eyez 162
8 years ago

This is in a localscript, this is also my first time actually making a gamepass, i never actually cared for it in the past, so if anyone can help me it'd be great, i am having problems with it:

local pewdiepass = 599082309
local gpserv = game:GetService("GamePassService")

if gpserv:PlayerHasPass(plr, pewdiepass) then
        subs.Value = subs.Value +785
        money.Value = money.Value +1250
    end

this is the error code:

Game passes can only be queried by a Script running on a ROBLOX game server

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

You're going to want to run this on the server, as opposed to the client, so put this in a server script. Also, you never defined "plr", "subs", or "money" and it'd be much easier if you used a .PlayerAdded function

local passId = 599082309
local gps = game:GetService('GamePassService')

game.Players.PlayerAdded:connect(function(player)
    local subs --Define this here
    local money --Define this here

    if gps:PlayerHasPass(player, passId) then
        subs.Value = subs.Value + 785
        money.Value = money.Value + 1250
    end
end)
0
i tried that same thing and it gave me the same error sad_eyez 162 — 8y
0
Go to "Configure your game" not "Configure this place" and enable "Enable Studio Access to API Services" RedneckBane 100 — 8y
0
I already did that, does my HttpService need to be on? sad_eyez 162 — 8y
View all comments (2 more)
0
Use :PlayerOwnsAsset() RedneckBane 100 — 8y
0
Nevermind, I figured it out, It is highly recommended by roblox to use PlayerOwnsAsset, i didn't read that part, but thanks for the help atleast, i will accept the answerfor your effort sad_eyez 162 — 8y
Ad

Answer this question