Why does my button not work?

When I try close the gui by pressing the exit button, nothing happens. Any ideas why?

local function donateButtonClicked(donateButton)

						local itemId = donateButton.Value.Value
						local itemPrice = donateButton.Price.Value

						MarketPlaceService:PromptPurchase(loser, itemId)

						MarketPlaceService.PromptPurchaseFinished:Connect(function(loser, itemId, was_purchased)

							if was_purchased then

								loser.leaderstats.Donated.Value += itemPrice
								local playerId = loser.UserId
								
								game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("[SYSTEM] "..loser.Name.." donated "..itemPrice.." robux to "..winnerName, "RBXSystem")
							else
								return
							end
							return
						end)
						return
					end

					for i,v in pairs(loser.PlayerGui.Donation.Frame.itemsScroller:GetChildren()) do
						if not (v:IsA("TextButton") or v:IsA("ImageButton")) then continue end
						v.MouseButton1Click:Connect(function()
							donateButtonClicked(v)
						end)
					end
					
					local exitButton = loser.PlayerGui.Donation.Frame.Exit

					exitButton.MouseButton1Click:Connect(function()
						loser.PlayerGui.Donation.Enabled = false
					end)
2 Likes

Have you tried adding few prints to check which sections of the script run or not?

1 Like

Well sometimes it works sometimes it doesn’t and it’s quite hard to test this because studio doesn’t let me access the testing players useriD so I have to go into the actual game with an alt.

whether something is written on the output, for example an error

And sorry for my English I use a translator

1 Like