I'm creating a tool for a game that has parts orbiting around the player. Currently, I'm listening for the RunService.Heartbeat
event in a module that moves three parts around a player. On the server, the parts move smoothly, but on the client, the parts move in a choppy manner. I'm aware that this is because the server can only send updates to the client at 20Hz, but I don't know how to approach switching this movement over to RenderStepped while still having the same look to other players. What should I do?
On the client: https://gyazo.com/472ec68efb53c460f7c6e2d0417a325e
On the server: https://gyazo.com/472ec68efb53c460f7c6e2d0417a325e
Here is my code:
local Jutsu = {} Jutsu.spawn = function(Player, Name, Antiex) local i = 0 local speed = 0.1 local speed2 = .03 local speed3 = .06 local incline = math.rad(45) local incline2 = math.rad(-45) local incline3 = math.rad(0) local distance = 5 local Scorch = script.Scorch local ball = Scorch:Clone() ball.Parent = workspace local ball2 = Scorch:Clone() ball2.Parent = workspace local ball3 = Scorch:Clone() ball3.Parent = workspace local planet = Player.Character.Torso spawn(function() wait(30) movement:Disconnect() ball:Destroy() ball2:Destroy() ball3:Destroy() end) movement = game:GetService("RunService").Heartbeat:Connect(function() i = i + 1 ball.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline, i * speed3, 0) * CFrame.new(0, 0, distance) ball2.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline2, i * -speed, 0) * CFrame.new(0, 0, distance) ball3.CFrame = planet.CFrame * CFrame.fromEulerAnglesXYZ(incline3, i * speed2, 0) * CFrame.new(0, 0, distance) end) end return Jutsu
Extra note: When I finish fixing the movement, I plan to add damage to all of the parts.
Instead use SetPrimaryPartCFrame:lerp(finishPos, acceleration)
or use BodyPosition
or BodyVelocity
.