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

What is wrong with this script? Please Help.

Asked by
Ulysies 50
9 years ago

Im trying to make a screen GUI shop and I want to be able to sell anything. But when I go to test it the button does nothing. the script is...

local assetId = 27112438

function die() script.Parent.MouseClick:connect(function(player) Game:GetService("MarketplaceService"):PromptPurchase(player, assetId) end) end

script.Parent.MouseButton1Down:connect(die)

0
Why put the function that sells the item inside a pointless function. Try replacing script.Parent.MouseClick:connect(function(player) with script.Parent.MouseButton1Down:connect(function(player) and delete the function die() and the event listener at the end MasterDaniel 320 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You made a mistake at events ;]

local assetId = 27112438

function die() script.Parent.MouseClick:connect(function(player) -- two functions :D 
Game:GetService("MarketplaceService"):PromptPurchase(player, assetId) end) end

script.Parent.MouseButton1Down:connect(die)

The problem you have is that you made a little confusion with events. You had already set the event, but then, you send the exact same event again. (This makes LUA confusion and breaks script)

Try removing the function die() and the last even listener, like MasterDaniel told you.

script.Parent.MouseClick:connect(function(player) Game:GetService("MarketplaceService"):PromptPurchase(player, assetId) end)

Hope this helps you! Thanks, marcoantoniosantos3

Ad

Answer this question