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
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
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)
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)
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?
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