Need help displaying GUI after purchase

I am by no means a scripter, I’m trying to learn how to do the simple things, and have been taking scripts and putting them together to see if I can achieve what I am going for.

Anyway, I have this script

MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
local productName

	if productId == 134468388 then
  game.ServerStorage.Admin:Clone().Parent=player.Backpack then 

player.PlayerGui:findFirstChild(“Info”) == nil then
gui = script.Info:clone()
gui.Parent = player.PlayerGui
repeat
wait(30)
gui:remove()
end
end
end

  -------------------------------------------------------------------

end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

“Info” is the name of the gui that is supposed to pop up after the purchase. From line 6 to line 11 is the Gui I added onto the purchase script. Buying the item isn’t the problem at all, instead it Line 6 to 11. I’ve tested the script and nothing happens after the purchase.

The error that shows up is “Error: (24,59) Expected identifier when parsing expression, got ‘then’
Line 24,26 being line 6,8 on here

if productId == 134468388 then
    game.ServerStorage.Admin:Clone().Parent=player.Backpack then

The second “then” is not being utilized for any conditional statements and is thus causing an error.

3 Likes

So what could the “then” be replaced with. When I remove it, there is an error at the “==” player.PlayerGui:findFirstChild(“Info”) == nil then

You are also missing an “if” before

player.PlayerGui:findFirstChild(“Info”) == nil then

That is why it is giving you another error

1 Like
MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local playerId = receiptInfo.PlayerId
    local player = getPlayerFromId(playerId)
    local productName
    if productId == 134468388 then
        game.ServerStorage.Admin:Clone().Parent=player.Backpack
    end
    if player.PlayerGui:findFirstChild(“Info”) == nil then
        local gui = script.Info:clone()
        gui.Parent = player.PlayerGui
        repeat
        wait(30)
        gui:remove()
    end
end	
end

  -------------------------------------------------------------------
end
return Enum.ProductPurchaseDecision.PurchaseGranted	
end

Edit: You also didn’t connect the receipt to this function. Also, it looks like some of these ends are extra unless you have more scopes beyond what is show here.

2 Likes

Added the “if and am still receiving the Error saying "
gui:remove()
until
end
end”

The first end said Error: Expected identifier when parsing expression, got ‘end’

sorry didn’t see your reply will test it out.

The ends came with the script, tried removing some, but they keep saying that they were expecting an identifier while parsing but got ___
And if I keep it, it says it’s expecting an “until” to close the repeat but got an end.
Thank you for your time btw

Repeat loops keeps going until the until condition is passed. They will error without one.

local condition = false
repeat print(“hello”) wait() until condition

^ would print hello until condition was equal to true.

2 Likes

It clearly says, either remove repeat or add until to it.If you want it to be cloned once just remove repeat(repeat is used to repeat an action until condition is met, that’s why you need until in it). :remove() is deprecated and you should replace it with :Destroy().

2 Likes

Thanks for the info, really helps

Thank you guys for all the help, all this is way too much for me and I think I will start off with an easier way of displaying a message. I hope this can help someone else tho.

1 Like

Please mark a solution for future readers to see with ease, you are welcome and no problem!

1 Like