Queue exhausted (Region3)

How do I avoid this message?
"Remote event invocation queue exhausted for Workspace.Generator.Part.RemoteEvent; did you forget to implement OnClientEvent? (128 events dropped)"
I do know what it means, but I do not know how to fix it, any ideas?

Script:

local part = script.Parent
local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)
local Run = game:GetService("RunService")
local Players = game:GetService("Players")
local RE = script.Parent.RemoteEvent
local players = {}

Run.Stepped:Connect(function()
	local character = nil
	local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i, part in pairs(partsInRegion) do
		if part.Parent:FindFirstChild("Humanoid") ~= nil then
			character = part.Parent
		elseif part.Parent.Parent:FindFirstChild("Humanoid") then
			character = part.Parent.Parent
		end
		if character then
			local player = game.Players:GetPlayerFromCharacter(character)
			RE:FireClient(player)
		end
	end
end)

LocalScript

local T = workspace.Generator.Part.RemoteEvent
local G = game.Players.LocalPlayer.PlayerGui.ScreenGui
local P = workspace.Generator.ProximityPrompt
local smallerNumber = 0
local biggerNumber = 50

T.OnClientEvent:Connect(function()
	P.Enabled = false
	G.Enabled = true
	for i = smallerNumber, biggerNumber, 0.1 do
		task.wait(0.1)
		script.Parent.Frame.Bar.Size = UDim2.new(math.clamp(i/biggerNumber, 0, 0.957), 0, 0.8, 0)
	end
end)**strong text**

Means you’re firing the remote too frequently, consider adding a debounce which prevents this.

Found the problem, although it fires multipletimes

How would I come to do that?
Even if I add a debounce I still want it detecting 24/7.

Does the client need to be fired every frame? This could be converted into a local script.

Not really, I need it to fire once when the player is inside of the region3.
And if the player gets out of the region 3 I need the gui to stop showing.

And what do you mean by converting it to a local script?
Everyone should be able to walk into the region and get X gui

You could handle this locally without needing to fire the client.

Example?
I don’t seem to understand how

My bad, I was just stupid.
I have converted it to being a LocalScript, the only problem now is that it is triggering to much.

Now you just need to add a cooldown.

Ok, I did add a Debounce but I am stuck.
I dont really know how I activate this script once it has already been executed.

local smallerNumber = 0
local biggerNumber = 50
local part = workspace.Generator.Part
local Run = game:GetService("RunService")
local G = game.Players.LocalPlayer.PlayerGui.ScreenGui
local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)
local debounce = true

Run.Stepped:Connect(function()
	local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i, part in pairs(partsInRegion) do
		if debounce == true then
			if part.Parent:FindFirstChild("Humanoid") ~= nil then
				debounce = false
				G.Enabled = true
				for i = smallerNumber, biggerNumber, 0.1 do
					task.wait(0.1)
					G.Frame.Bar.Size = UDim2.new(math.clamp(i/biggerNumber, 0, 0.957), 0, 0.8, 0)
				end
			end
		end
	end
end)

I was thinking about adding a debounce = true at the end but then it just triggered to much again.

local smallerNumber = 0
local biggerNumber = 50
local part = workspace.Generator.Part
local Run = game:GetService("RunService")
local G = game.Players.LocalPlayer.PlayerGui.ScreenGui
local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)

local debounce = false

Run.Stepped:Connect(function()
	local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i, part in pairs(partsInRegion) do
		if part.Parent:FindFirstChild("Humanoid") ~= nil then
			if debounce then return end
			debounce = true
			G.Enabled = true
			for i = smallerNumber, biggerNumber, 0.1 do
				task.wait(0.1)
				G.Frame.Bar.Size = UDim2.new(math.clamp(i/biggerNumber, 0, 0.957), 0, 0.8, 0)
			end
			task.wait(0.1)
			debounce = false
		end
	end
end)

Change the 0.1 bit for a shorter/longer cooldown.

Thank you so much for the help!

Why can’t you check magnitude every frame instead of looping through up to 1000 isntances?