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

My gamepass script wont work in an actual game but works in studio ?

Asked by 6 years ago

I have this script to check if the player owns a gamepass and it works in studio but not in the actaul game, why ?

id = 1008824264
wait(10)
for i,v in pairs(game.Players:GetPlayers()) do
    if v then
        if game:GetService("GamePassService"):PlayerHasPass(v,id) then
            wait(1)
            game.Players.LocalPlayer.leaderstats.Points.Value = game.Players.LocalPlayer.leaderstats.Points.Value + 250
            game.Players.LocalPlayer.PlayerGui.MEGAVIPWALK.Enabled = true   
        end
    end
end

0
Why do you need to do "if v then"? hiimgoodpack 2009 — 6y
2
you cant use localplayer in a serverscript... R_alatch 394 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
id = 1008824264
wait(10)
for i,v in pairs(game.Players:GetPlayers()) do
    if game:GetService("GamePassService"):PlayerHasPass(v,id) then
        wait(1)
        v.leaderstats.Points.Value=v.leaderstats.Points.Value + 250
        v.PlayerGui.MEGAVIPWALK.Enabled = true   
    end
end

Just change game.Players.LocalPlayer to v because game.Players.LocalPlayer doesn't work in server side scripts.

0
Explain your answer in English. Don't just post code; this doesn't help the poster or the community understand why the code does what it does. hiimgoodpack 2009 — 6y
Ad

Answer this question