Trying to make a ingame shirt seller.
script.Parent.MouseButton1Down:connect(function(player) game:GetService("MarketplaceService"):PromptPurchase(player,379581503) end)
It keeps saying unable to cast value to object. Unsure why. It's a surface gui with a button.
Here's your main problem:
Player isn't really defined well in this function. To make this easier,
1. I would use a local script to get player. ** **2. connect button to click function (ex. game.Workspace.Part.SurfaceGui.Button) and connect it with MouseButton1Down:connect(buy)
player = game.Players.LocalPlayer part = game.Workspace.Part.SurfaceGui.Button -- Where the SurfaceGui Button is located id = 379581503 function buy() game:GetService("MarketplaceService"):PromptPurchase(player,id) end part.MouseButton1Down:connect(buy)
You need to be specific about your Variables etc, I recommend using locals. Locals are like this:
local answer = Workspace.Answer.Value -- Or answer = Workspace.Answer.Value (maybe..)