Gamepass item giver not working

I have a script that when it detects you have a certain gamepass takes the item from server storage and places it in your backpack. The script works in other games but not this one and I am really confused. Any help appreciated.

Script:

local MarketPlaceService = game:GetService(ā€œMarketplaceServiceā€)

local GamepassId = 15090522
local Tool = game.ServerStorage[ā€œGoldenBoomBoxā€]

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
end
end)
end)

1 Like

image

I feel like you may need to turn this on if possible, also check if the Tool is equal to where it actually is

Are you using an alt account? Cause thereā€™s someone else who asked for the exact same thing.

No iā€™m not, idk what is going on

try replacing

local Tool = game.ServerStorage["GoldenBoomBox"] 

with

local Tool = game.ServerStorage:WaitForChild("GoldenBoomBox")

Still no luck, thereā€™s no output either

Hello!

I added pcall for security reasons, otherwise, this code definitely works. Try printing out hasGamePass value. Are you sure you own a gamepass? Is the gamepass ID correct? Make sure that the script (server script) is located in ServerScriptService (I accidentally put it inside ServerStorage at first :sweat_smile: ). Third party sales can be disabled and character is also already loaded by the time tool is copied.

local MarketPlaceService = game:GetService("MarketplaceService")

local GAMEPASS_ID = 15090522

-- correct path required
local tool = game:GetService("ServerStorage")["Golden Boom Box"]

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local hasGamePass; local success, err = pcall(function()
			hasGamePass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
		end)
		if (not success) then
			warn("Something went wrong while trying to access user's gamepass data.")
		end
		if (hasGamePass) then tool:Clone().Parent = player.Backpack end
	end)
end)
1 Like