This is my current code which is in a script in ServerScriptService
local tool = game.Lighting.Glock17 local gamepass = 4893873 local function onPlayerAdded(plr) local hasPass = false if game:GetService("GamePassService"):PlayerHasPass(plr, gamepass) then tool:Clone().Parent = game.Players.LocalPlayer.Backpack else print("player doesn't own pass") end end
This is an updated script but still doesn't work
local tool = game.Lighting.Glock17 local gamepass = 4893873 local function onPlayerAdded(plr) local hasPass = false if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr, gamepass) then tool:Clone().Parent = game.Players.LocalPlayer.Backpack else print("player doesn't own pass") end end
Use UserOwnsGamePassAsync from the MarketplaceService instead. After the gamepass update, you need to use this method instead.
Try...
local allow = ( game:GetService('MarketplaceService'):UserOwnsGamePassAsync(player.userId, 1234567) -- Paste your game pass id here ) if allow then -- continue with script
UserId
of the player, not the Player
object itself. Also, why are you using LocalPlayer
when it is nil
on the server and you already had the player defined? It is also worth mentioning that Lighting
should not be used as storage, use ReplicatedStorage
or ServerStorage
.local tool = game.ReplicatedStorage.Glock17 local gamepass = 4893873 local MarketplaceService = game:GetService("MarketplaceService") local function onPlayerAdded(plr) local hasPass hasPass = MarketplaceService:UserOwnsGamePassAsync(plr.UserId, gamepass) if hasPass then tool:Clone().Parent = plr.Backpack else print("player doesn't own pass") end end