Hello!
I am creating very simple script to check if a player owns a tshirt, if they do then fire a RemoteEvent and if they do not then prompt the purchase of the tshirt and if the outcome is that the player bought it, then the same RemoteEvent will be fired.
LocalScript inside a text button:
local MPS = game:GetService("MarketplaceService")
local ID = 1234 --removed actual id for now
local ts = game:GetService("TweenService")
script.Parent.MouseButton1Click:Connect(function(player)
if MPS:PlayerOwnsAsset(player, ID) then --error occurs here!!!
game.ReplicatedStorage.ShirtEvent:FireServer(game.Players.LocalPlayer)
else
MPS:PromptPurchase(player, ID)
MPS.PromptPurchaseFinished:Connect(function(player, ID, isPurchased)
if isPurchased == Enum.ProductPurchaseDecision.PurchaseGranted then
game.ReplicatedStorage.ShirtEvent:FireServer(game.Players.LocalPlayer)
elseif isPurchased == Enum.ProductPurchaseDecision.NotProcessedYet then
--placeholder for now
else
print("invalid")
end
end)
end
end)```