Rotating Parts around a point help

  1. What do you want to achieve?
    I’m messing around with rotating spheres around a specific position, both a stationary position and a moving position.

  2. What is the issue?
    I’m having some trouble getting the visuals to work so that everyone can see them. But right now only the server or 1 player can see it not both/all.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    At first I tried to implement the position updating through a server script using run service heatbeat:wait() or stepped:wait() etc. within a while loop but, the visual was very choppy and the positions didn’t seem to be correct as the spheres rotated.

Next I tried using the BindToRenderStep function from the same script (server) and the animation was perfect but only could be seen from server perspective.

Then I tried running the BindToRenderStep through a local script given to the player, again the animation works smoothly but only that 1 client can see it.

I activated the BindToRenderStep function using a remote event after the player touched a part. So I thought about just using “FireAllClients” but that seems like overkill maybe? So I was just wondering if anyone could provide me with some tips on how I should handle this situation or if I should be doing things much differently. Thanks.

1 Like

I went back and tried the first thing again. I think the problem that first time was that I did not have the spheres anchored so they kept “falling” out of position. This first method works well for everyone to see the animation except for the client who touched the part. While the point position moves, the spheres lag behind but this only happens for the specific client, Player2 and the server perspective both show the spheres staying in the proper position as the point position moves.

Edit: I tried to combine this with the bindToRenderStep code on the local script but the lag behind issue remains a problem.

Script Snippet:

local degree = {0, 120, 240}
while true do
    for i=1, #spheres do
	if(degree[i] == 361) then degree[i] = 0 end
	spheres[i].CFrame = pointPosition.CFrame * CFrame.Angles(0, math.rad(degree[i]), 0) *,2,10)
        degree[i] = degree[i]+1

@Emskipo im not quite sure what your are trying to do exactly.

Are you trying to make a single part rotate, or one part that moves other parts like a door hinge?

Well first I was just trying to get a part to rotate around a point. So like a sphere that floats around a stationary box and then make it so that the rotation could be seen by all parties (clients/server). I got that sorted. When I put that into a more complex situation like a player driving a car. The client driving the car renders the spheres lagging behind the car. When the car stops, the spheres catch up. The lag only seems to happen with the client driving the car. Testing with 2 players in studio, the server perspective shows the spheres rotating perfectly around the car, and the same is true for the 2nd player. But the player driving the car shows them lagging behind.

So are you asking how to fix the client lag?

1 Like

I seem to have solved the problem. When I implemented the rotation code on just the server the client would show the rotating spheres lagging behind the car. When I implemented in on just the client, only that client could see the spheres. So I ended up having to implement it on both the server and the client. One of the issues I ran into while I was messing with this is that I placed the code to fireClient after the infinite loop for the rotation code on the server. So the client never actually started its code. That caused some confusion for me. After I moved the fireClient event before the loop it started working properly.

1 Like