I am making a script that lets a user purchase multiple gamepasses from a shop. Other scripts prompt the purchase fine but the script linked does not give the player the item. I used print statements to root out the problem and found it was the :UserOwnsGamepassAsync(). I have no idea what is wrong with it. Please help!
local marketPlaceService = game:GetService("MarketplaceService")
local rainbowTitleId = 14279002
local balloonId = 14280017
local segwayId = 14280023
local vipId = 14280028
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if marketPlaceService:UserOwnsGamePassAsync(player.UserId, rainbowTitleId) then
game.ServerStorage:WaitForChild("OverheadGui"):Clone().Parent = character:WaitForChild("Head")
end
if marketPlaceService:UserOwnsGamePassAsync(player.UserId, balloonId) then
game.ServerStorage:WaitForChild("GreenBalloon"):Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage:WaitForChild("GreenBalloon"):Clone().Parent = player:WaitForChild("StarterGear")
end
if marketPlaceService:UserOwnsGamePassAsync(player.UserId, segwayId) then
game.ServerStorage:WaitForChild("HandlessSegway"):Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage:WaitForChild("HandlessSegway"):Clone().Parent = player:WaitForChild("StarterGear")
end
end)
end)
local marketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local rainbowTitleId = 14279002
local balloonId = 14280017
local segwayId = 14280023
local vipId = 14280028
function UserOwnsGamePassAsync(PlayerID,GamePass)
local Success,Results = pcall(function()
return marketPlaceService:UserOwnsGamePassAsync(PlayerID,GamePass)
end)
print(Success,Results)
if Success and Results then
return true
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if UserOwnsGamePassAsync(player.UserId,rainbowTitleId) then
ServerStorage:WaitForChild("OverheadGui"):Clone().Parent = character:WaitForChild("Head")
end
if UserOwnsGamePassAsync(player.UserId, balloonId) then
ServerStorage:WaitForChild("GreenBalloon"):Clone().Parent = player:WaitForChild("Backpack")
ServerStorage:WaitForChild("GreenBalloon"):Clone().Parent = player:WaitForChild("StarterGear")
end
if UserOwnsGamePassAsync(player.UserId, segwayId) then
ServerStorage:WaitForChild("HandlessSegway"):Clone().Parent = player:WaitForChild("Backpack")
ServerStorage:WaitForChild("HandlessSegway"):Clone().Parent = player:WaitForChild("StarterGear")
end
end)
end)
no no no no no, you made a function called UserOwnsAssetAsync(), where do you put that function? im not talking about the script im talking about the function you used a pcall in