Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with surface gui?

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.

2 answers

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)

2 comments

0

It's still not working

0

It worked, I've tried it. It's something that you've set up wrong I believe.

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..)

This discussion is preserved as it was. New answers, comments, and votes are closed.