I tried to apply two scripts to many models but it doesn't work as I wanted

I wanted to apply a money taking script to many models but when I press the E key it collects all the money

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.Character:Wait()
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")



UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then	
		for _, v in pairs(game.Workspace.Moneys:GetChildren()) do
			local magnitude = (HumanoidRootPart.Position - v.Position).Magnitude

			if magnitude <= 10 then
				--	v:Destroy()
				--	v.BigReward:Play()
				game.ReplicatedStorage.MoneyRemote:FireServer()
			end
		end
	end
end)
game.ReplicatedStorage.MoneyRemote.OnServerEvent:Connect(function()
	for _, v in pairs(game.Workspace.Moneys:GetChildren()) do
		v.BigReward:Play()
		--wait(0.1)
		v:Destroy()
	end
end)

Sorry if the script is bad I’m new to scripting

Add a cooldown, like this:

local Cooldown = 1
game.ReplicatedStorage.MoneyRemote.OnServerEvent:Connect(function()
	for _, v in pairs(game.Workspace.Moneys:GetChildren()) do
		v.BigReward:Play()
		--wait(0.1)
		v:Destroy()
		wait(Cooldown)
	end
end)

this should work:

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.Character:Wait()
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
local Magnitudes = {}

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then	
		for _, v in pairs(game.Workspace.Moneys:GetChildren()) do
			local magnitude = (HumanoidRootPart.Position - v.Position).Magnitude
			if magnitude <= 10 then
				Magnitudes[v] = magnitude
				table.sort(Magnitudes, 
					function(a, b)
						return a[2] < b[2]
					end
				)
				for _, money in pairs(Magnitudes) do
					game.ReplicatedStorage.MoneyRemote:FireServer(Magnitudes[1])
				end
			end
		end
	end
end)
game.ReplicatedStorage.MoneyRemote.OnServerEvent:Connect(function(Plr, Money)
	Money.BigReward:Play()
	task.wait(0.1)
	Money:Destroy()
end)

Do you have another script that picks up the OnServerEvent? If you do, roblox will only fire to one of them.