Remote event sending too much requests

Hey
Im using Renderstepped for a script that use the humanoid position and send it to a server script but using it is a bit problematic because the remote event cant send that much events
I cant use something else than Renderstepped since they are too slow to makes the script work propely

What should i do to fix this ?

local hum = plr.Character:FindFirstChild("Humanoid")
local RunService = game:GetService("RunService")
local ThrowerValue = plr:WaitForChild("leaderstats"):WaitForChild("Folder"):WaitForChild("ThrowerValue")

RunService.RenderStepped:Connect(function()
	
	if ThrowerValue.Value == 0 then
	
	-------UP
	
	if hum.MoveDirection.X <= -0.5 then
		event:FireServer()
	end
2 Likes

Why do you want to send remote events that quick? It’ll definitely lag the game

Using a loop did not work
I asked in my previous post how could i fix this and renderstepped was the solution apparently

You are firing the remote event inside a RenderStepped Event, the event would be fired too quickly. However, you can just check for hum.MoveDirection.X on the server itself, there isn’t a need to do this on the client. Simply use the PlayerAdded event to do this.

local runService = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(player)
      local character = player.Character or player.CharacterAdded:Wait()
      local humanoid = character:WaitForChild("Humanoid")
      runService.RenderStepped:Connect(function()
            if hum.MoveDirection.X <= -0.5 then
                  
            end
      end)
end)

1 Like

No, like what’s the purpose of sending remote events that quickly?

The ouput tells me that RenderStepped can only be used from local scripts

Checking constantly the humanoid.MoveDirection and knowking in which direction is the player going to

1 Like

Use RunService.PreRender instead

or better yet, use RunService:BindToRenderStep()

Why not do it in the server? Too many remote events in a short amount of time will lag both the server and client

1 Like

Using RunService.PreRender is still giving the same result i can still try to use RunService:BindToRenderStep() but i dont know how could i insert this function into my script since its the first time that im seeing it

local part = game.Workspace.Part2
local ts = game:GetService("TweenService")
local Rs = game:GetService("RunService")

info = TweenInfo.new(4, Enum.EasingStyle.Linear)
info2 = TweenInfo.new(0.5, Enum.EasingStyle.Linear)

toggle = false

game.Players.PlayerAdded:Connect(function(plr)
	
	wait(1)
	
	local char = plr.Character
	local hum = char:FindFirstChild("Humanoid")
	
	Rs.PreRender:Connect(function()
	
	--UP
	
	if hum.MoveDirection.X <= -0.5 then
	local track = ts:Create(part,info2,{["CFrame"]=part.CFrame * CFrame.Angles(70, 0, 0)})
	track:Play()

	if hum.MoveDirection.X >= 0 then
		track:Pause()
	end
	end
	
	--DOWN

	if hum.MoveDirection.X >= 0.5 then
		local track = ts:Create(part,info2,{["CFrame"]=part.CFrame * CFrame.Angles(-70, 0, 0)})
		track:Play()

		if hum.MoveDirection.X >= 0 then
			track:Pause()
		end
	end
	
	--RIGHT

	if hum.MoveDirection.X <= -0.5 then
		local track = ts:Create(part,info2,{["CFrame"]=CFrame.new(-767.502, 284.466, -36.469)* CFrame.Angles(0, math.rad(-90), 0)})
		track:Play()

		if hum.MoveDirection.X >= 0 then
			track:Pause()
		end
	end
	
	--LEFT

	if hum.MoveDirection.X >= 0.5 then
		local track = ts:Create(part,info2,{["CFrame"]=CFrame.new(-767.502, 284.466, 383.379)* CFrame.Angles(0, math.rad(-90), 0)})
		track:Play()

		if hum.MoveDirection.X >= 0 then
			track:Pause()
		end
	end

end)
end)

Because the RenderStepped event is not working server sided

1 Like

try

RunService:BindToRenderStep(plr.Name.."CheckMoveDir", Enum.RenderPriority.Last.Value, function()
	-- check move direction code
end)

To disconnect just do

RunService:UnbindFromRenderStep(plr.Name.."CheckMoveDir")

Its also not working
iiiiiiiii

1 Like

For what reason are we using RenderStepped instead of Heartbeat?

I reread the OP and you said that anything else is too slow? I don’t think RenderStepped and Heartbeat makes a difference here. Could you further clarify on why it was slow?

2 Likes

You can do Heartbeat in server to check the player’s humanoid direction

1 Like

when i was saying that it was too slow i was talking about heartbeat in a local script but using it in a server script worked for me thank you !

Hi . This is just a suggestion but . You should use unreliable remote event instead of regular remote events . Unreliable remote events are less memory intensive. However, the message fired by an unreliable remote event is not guaranteed to be passed

2 Likes