Does client stepped function run faster then servers?

So I’m creating this anchored project laser thing, and I have the laser first created on the server and setup it’s properties like Velocity and Position, and then on the client-side right when that laser fomr the server is created I create a client copy and also setup the same initial properties and then I have a Stepped looped on the client and the server that both handle the same exact physics calculations and logic to move the lasers, but a problem I had run into which I think I fixed now is the laser on the client would be ahead of the laser on the server and it would be more noticable the faster the laser got, and

Basically I would lerp the positions I got from the updated properties after doing the physics calculations on the server and the client

function module.moveLasers(tracker, folder, dt)
   for _, laser in ipairs(folder:GetChildren()) do
      local velocity = tracker[laser.Name].Velocity
      local position = tracker[laser.Name].Position
      if RunService:IsServer() then
         laser.CFrame = laser.CFrame:Lerp(CFrame.new(position, position + velocity), dt * 100)
      else
         laser.CFrame = laser.CFrame:Lerp(CFrame.new(position, position + velocity), dt * 100)
      end  
   end
end

I lerped them by a factor of 100 on both the client and the server, and it would look something like this

But when I would adjust the clients lerp factor to 40 and it would look way more in sync?

I’m unsure of what I’m saying but they are different, not on all cases though, the client one depends on the user’s device, more FPS means less delta time, you probably know that, for the server, they are run on Roblox servers which, as far as I know, have a fixed frame rate, how much? I really don’t know. I can’t assure you this is exactly it but it should be, also player’s ping could be affecting it but since your in studio and assuming you didn’t change the ping settings thing, I wouldn’t take that as a solution.

2 Likes

Hm, do you think clamping delta time could make any difference, also I’m gonna hop into an actual live game and see how it looks

1 Like

No, that would be weird, one thing though, why do you need to handle this both on client and server? U should just handle it on all clients and do the final “thing?” on the server, like if ur using it for damage then do the movement on the client and guess the time it’ll hit at, for example, 60 frames and apply damage after enough time has passed. speed = distance/time in case you couldn’t guess that from my explanation, just simple physics.

2 Likes

Honestly, after reading your reply I’m actually not entirely sure why I’m handling both movement on the server and also the client, I was going to like have the server lasers have a transparency of 1, so clients couldnt see them but I guess so I could have a record of where the laser actually is relative to when it either hit a wall or when it was interacted by a player?

I mean that sounds reasonable?

1 Like

I meeaaan, I guess you’re convinced by that now lmao, tell me if u had problems implementing it.

1 Like

BUT I actually do see where your coming from and that actually gave me an idea where alright let’s say the client are taking care of the movement for the lasers, and then on someones client it hits a wall, so im guessing id do that change on the client and then fire a remote telling the server it hit the wall and then maybe have other clients also verify that laser hit the wall and if a certain percent of players agree it hit the wall then replicate it too everyone??

1 Like

The laser shouldn’t move this slow so all you would need to do is just shooting a ray from the server to the target position and see where it hits, if it did hit then wait some time, get that time using the formula I gave you above, and after the wait you just damage or do whatever.

1 Like