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

My gamepass script isn't giving tools?

Asked by 8 years ago

So i'm trying to make a gamepass give you some tools. Problem is, I can't actually get it to give the tools.

Output log: 18:49:41.123 - Workspace.Script:11: attempt to index global 'Player' (a nil value)

local passId = 363035405 -- change this to your game pass ID.


function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
    Weapon = game.Lighting.Grinder:Clone()
Weapon.Parent = Player.Backpack
    end
end)

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

You used a variable that wasn't defined on line 11 -- "Player". In that function, you have the player parameter set to "plr", so the script should be:

local passId = 363035405 -- change this to your game pass ID.


function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        Weapon = game.Lighting.Grinder:Clone()
        Weapon.Parent = plr.Backpack
    end
end)

Hope this helped!

Ad

Answer this question