SendNotification Is Resending Notifications

In my script, it’s expected to send only one notification of something but sometimes it ends up sending multiple and messes with the scripts function somehow and I really don’t know what is causing it as it wasn’t doing this before. Here’s an example:
image

You should also provide your

1 Like
game:GetService("StarterGui"):SetCore('SendNotification', {
				Title = 'Notification',
				Text = "Please say the amount of coins to give to the player!",
				Duration = 5
			})
			script.Notification:Play()

Not what they meant, they meant the entire script top to bottom, not the part that creates the notification…

1 Like
game:GetService("StarterGui"):SetCore('SendNotification', {
				Title = 'Notification',
				Text = "Please say the amount of coins to give to the player!",
				Duration = 5
			})
			script.Notification:Play()
			local Amount = nil
			local t2
			delay(15, function()
				if Amount == nil then
					game:GetService("StarterGui"):SetCore('SendNotification', {
						Title = 'Notification',
						Text = "Timed out.",
						Duration = 5
					})
					script.Notification:Play()
					t2:Disconnect()
					return
				end
			end)
			t2 = game:GetService("Players").LocalPlayer.Chatted:Connect(function(Message)
				Amount = Message
				if game.Players:FindFirstChild(result[2]) then
					event:FireServer("AddCoins", game.Players:FindFirstChild(result[2]), Message)
					t2:Disconnect()
				end
			end)

Adding a debounce should fix this.

What do you mean add a debounce, how is that gonna help.

A debounce is (most likely) a boolean check that checks if there is a certain function that gets called way too many times. If the debounce is activated, the function will no longer run since debounce is true

local debounce = false
-- your code
if debounce then return end
game:GetService("StarterGui"):SetCore('SendNotification', {
				Title = 'Notification',
				Text = "Please say the amount of coins to give to the player!",
				Duration = 5
			})
task.wait(1) -- set a time
debounce = false
-- your code