Title.
I own the GamePass, so I receive the item while testing. But, when I run the game for real (outside of Studio) I don't receive the GamePass.
F.Y.I, I used the default script from the Dev Article here.
Code:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 4973716 -- Change this to your game pass ID
local function onPlayerAdded(player)
local hasPass = false
-- Check if the player already owns the game pass
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
-- If there's an error, issue a warning and exit the function
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
print(player.Name .. " owns the game pass with ID " .. gamePassID)
--The Below code gives the Gamepass owner the Gamepass
local sword = game.ServerStorage["Death Hammer"]:Clone()
sword.Parent = game.Players.LocalPlayer.Backpack
sword:Clone().Parent = game.Players.LocalPlayer.StarterGear
--End
end
end
-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
Players.PlayerAdded:Connect(onPlayerAdded)
Thanks, Mex

2 comments
LocalPlayer is nil on the server
Oh, I see. What would I call instead? Thanks, again