Remote event runs twice

For some reason my remote event runs twice idk why, please help me.
local script:

checkAutoDelete.OnClientEvent:Connect(function(button)
	if script.Parent:FindFirstChild(button).AutoDelete.Visible == true then
		local autoDelete = true
		backToServerAutoDelete:FireServer(autoDelete)
	elseif script.Parent:FindFirstChild(button).AutoDelete.Visible == false then
		local autoDelete = false
		backToServerAutoDelete:FireServer(autoDelete)
	end
end)

part of the serverscript:

checkAutoDelete:FireClient(player,button)
		
		backToServerAutoDelete.OnServerEvent:Connect(function(player,autoDelete)
			
			openBox:FireClient(player,button,boxName,autoDelete)
			if autoDelete == false then
				local newButton = Instance.new("StringValue")
				newButton.Name = button
				newButton.Value = button
				newButton.Parent = player.ButtonInventory

				newButton:SetAttribute("MoneyMultiplier",game:GetService("ReplicatedStorage").Boxes:FindFirstChild(boxName):FindFirstChild(button):GetAttribute("MoneyMultiplier"))
			end
		end)
3 Likes

could you give more context on which runs twice (client or server)

2 Likes

the back to serverautodelete event runs twice sorry for low context

3 Likes

can you add two prints? one behind backToServerAutoDelete:FireServer(autoDelete) in the local script and another at the beginning of the OnServerEvent connection and see what happens?

3 Likes

I already did that myself I printed in every remote event and only in the backToServer it ran twice

3 Likes

if you remove the line

elseif script.Parent:FindFirstChild(button).AutoDelete.Visible == false then
		local autoDelete = false
		backToServerAutoDelete:FireServer(autoDelete)

would that make any difference at all?

2 Likes

nope still the problem it also only happends the seconds time its really weird

3 Likes

Couldn’t you just use a remote function? like invoke it then it the server is ok it returns true otherwise it returns false?

2 Likes

Can you show a clip of what happens and with prints?

1 Like