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

What is wrong with this script? Please Help.

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)

1 comment

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

1 answer

✓ Accepted answer

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

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