This script errors with "Unable to cast value to Object" I am not sure why as I'm pretty sure I'm including the player object. Let me know why.
Errors on Lines 51, 55, and 59 depending on which button you click.
local product1 = 616014127
local product2 = 616014380
local product3 = 616014575
--------------------Main stuff-----------------------------------------------------------
local datastore = game:GetService("DataStoreService")
local market = game:GetService("MarketplaceService")
local totalamount = datastore:GetDataStore("RobuxRaised")
local datakey = ("aafneueu7378348734bg")
local product1price = market:GetProductInfo(product1,Enum.InfoType.Product).PriceInRobux
local product2price = market:GetProductInfo(product2,Enum.InfoType.Product).PriceInRobux
local product3price = market:GetProductInfo(product3,Enum.InfoType.Product).PriceInRobux
local button1 = script.Parent.Donate1.SurfaceGui.TextButton
local button2 = script.Parent.Donate2.SurfaceGui.TextButton
local button3 = script.Parent.Donate3.SurfaceGui.TextButton
local raisedtext = script.Parent.TotalDonated.SurfaceGui.TextLabel
--[[
local loadamount = totalamount:GetAsync(datakey)
if not loadamount then
pcall(function()
totalamount:SetAsync(datakey,0)
end)
else
raisedtext.Text = "Total Donated: "..loadamount.."R$"
end
while true do
raisedtext.Text = "Total Donated: "..loadamount.."R$"
wait(3)
end
--]]
button1.Text = product1price.." R$"
button2.Text = product2price.." R$"
button3.Text = product3price.." R$"
button1.MouseButton1Down:Connect(function(plr)
market:PromptProductPurchase(plr,product1) --These error
end)
button2.MouseButton1Down:Connect(function(plr)
market:PromptProductPurchase(plr,product2) --These error
end)
button3.MouseButton1Down:Connect(function(plr)
market:PromptProductPurchase(plr,product3) --These error
end)

3 comments
If I'm not mistaken, it's market:PromptProductPurchase(product, plr) that's why. The player is an object and you need a value.
Nope, the player object argument comes before the asset argument.
Yeah. I was mistaken.