My game pass script doesn’t work

local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId,THE GAMEPASS ID)

if ownsGamepass then
local sword = game:GetService(“ReplicatedStorage”):WaitForChild(“Sword”):Clone()
sword.Parent = player.Backpack
end local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId, GAMEPASS ID)

if ownsGamepass then
local sword = game:GetService(“ReplicatedStorage”):WaitForChild(“Sword”):Clone()
sword.Parent = player.Backpack
end

What’s the problem? Also you’re doing this on a localscript so the sword will only appear to the LocalPlayer and won’t work against other players.

The problem is it doesn’t appear on the players inventory.

Try doing it on a server script under a CharacterAdded event.

I had studio open and tried it and it worked thanks!

1 Like

No problem, remember to always use server scripts when giving items or they won’t work.