Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with surface gui?

Asked by 8 years ago

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

Log in to vote
0
Answered by
yoshi8080 445 Moderation Voter
8 years ago

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)
0
It's still not working TheScriptingAccount 90 — 8y
0
It worked, I've tried it. It's something that you've set up wrong I believe. yoshi8080 445 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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

Answer this question