An error in my script keeps showing up; giving me " (Bad Request) " even though I don’t know what I’m doing incorrectly. The script runs through fine as it runs through all the values and gives the total value at the end. However, :PlayerOwnsAsset() is the part that is penalizing the rest of the script.
The purpose of the script is to run through all the ID’s and check to see if the player owns that asset (this is shirts, t-shirts, and pants only); how am I suppose to organize the code for it to work properly?
function ClothingVerification()
local Players = game:GetService("Players").LocalPlayer
local Assets = {5001890347, 5001891887, 3570551691, 5152114157, 5152115916}
local Total = 0
for i, value in pairs (Assets) do
if game:GetService("MarketplaceService"):PlayerOwnsAsset(Players, i) then
print(value)
Total = Total + 1
print("Sucessful")
else
print("Don't Have")
print(value)
end
end
print(Total)
end
I agree you should fire an asset check event from the client to the server, check when you player joins (.PlayerAdded) or when the character is added (.CharacterAdded). Second, your for loop should be this anyways.
for i, assetId in pairs(Assets) do
if game:GetService("MarketPlaceService"):PlayerOwnsAsset(Players, assetId) then
-- You were checking the index of Assets not the actual AssetId
print(assetId)
Total += 1
print("Successful")
else
print(assetId)
print("Don't have")
end
end