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**
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.
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)