Remote event firing repeatedly

Hi!
I want the remote event to send the values ​​from the player to the server.
And then the server sends the values ​​to all the players.
The problem is that the remote event is fired six times in a row. It only needs to be fired once.
(This is a ticket system. You enter the data and it creates a ticket, but at the moment it creates six similar tickets)
I checked for a bug and changed the script a bit. Now this function also doesn’t work where it should check if all the fields are filled
I’ve been looking for help and trying to rewrite, but can’t find a solution.

I also mention that I am actually a 3D modeler and I don’t know much about scripting, but sometimes I also need to script.

--var--
local Inputs = script.Parent.Inputs
local MainFrame = script.Parent
local Give = game.ReplicatedStorage.SystemEvents.TabletGiveInfo
local Get = game.ReplicatedStorage.SystemEvents.TabletGetInfo
--

--
local function fillfieldns()
	
end
--Check Fields--
MainFrame.AddTicketToList.MouseButton1Click:Connect(function()
	
	for i, v in pairs(MainFrame:GetChildren()) do
		if v.ClassName == "TextBox" then
			if #v.Text <= 0 then
				MainFrame.Warning.Visible = true
				wait(3)
				MainFrame.Warning.Visible = false
			else
				Inputs.AriPort.Value = MainFrame.AriPort.Text
				Inputs.DepPort.Value = MainFrame.DepPort.Text
				Inputs.DepTime.Value = MainFrame.DepTime.Text
				Inputs.AriTime.Value = MainFrame.AriTime.Text
				Inputs.TicketCost.Value = MainFrame.TicketCost.Text
				Inputs.Vessel.Value = MainFrame.Vessel.Text
				wait(1)
				local AriPort = Inputs.AriPort.Value
				local DepPort = Inputs.DepPort.Value
				local DepTime = Inputs.DepTime.Value
				local AriTime = Inputs.AriTime.Value
				local TicketCost = Inputs.TicketCost.Value
				local Vessel = Inputs.Vessel.Value
				wait(1)
				Give:FireServer(AriPort,DepPort,DepTime,AriTime,TicketCost,Vessel)
				wait(1)
			end
		end
	end
end)
MainFrame.Reset.MouseButton1Click:Connect(function()
	for i, v in pairs(MainFrame:GetChildren()) do
		if v.ClassName == "TextBox" then
			v.Text = " "
		end
	end
end)
MainFrame.ActiveTicketsButton.MouseButton1Click:Connect(function()
	script.Parent.Parent.ActiveTickets.Visible = true
end)
MainFrame.Parent.ActiveTickets.Close.MouseButton1Click:Connect(function()
	MainFrame.Parent.ActiveTickets.Visible = false
end)

you know that you are looping right?

That’s right. I forgot that it also repeats the remote event as much as I have textboxes
I will add it as a separate function.
Thank you!

I suggest adding a debounce too, this will prevent the function from being executed too frequently.

1 Like