How do you use CFrame locally

I’m trying to make a moving model using CFrame, Not using Server Script because In-Game it’s very laggy.

This is the script in the actual game.

This is the script in studio, there’s a huge difference.

This is the CFrame script i was using in the Model, I just don’t know how to make a run locally and fire it on all clients at the same time.

local vehicle = script.Parent
local speed = 5-- studs per second
game:GetService("RunService").Heartbeat:Connect(function(dt) -- 'dt' is the time in seconds since the last physics frame, we can use it to more accurately calculate the vehicle's position WRT time.
	vehicle:SetPrimaryPartCFrame(vehicle.PrimaryPart.CFrame *, 0, 0 * speed * dt))

I’m new to scripting so I may not know some things.


Try setting the vehicle networkowner to the server.


Wouldn’t that put more pressure on the server tho? He’s trying to reduce lag. I’m not sure if it does that or not.

Maybe try watching this video since it may solve a similar issue to yours:

This video will show you how to make things move without lag. Starts at 46:27 btw. Just watch it and it will give you an idea.

1 Like

In the video he is literally doing what I said, setting the network owner to the server from a local script, in fact in the api reference he recommends you to set it to nil (server) .

But did you not watch the whole video. He states that its now the server that has all the pressure on calculating all the physics 47:50. He suggests a better option.


Like @gmtojay said as well, it would be better to move the moving parts locally. In that video, it shows an example.

1 Like

Well yeah, I haven’t continued watching the video, maybe putting the movement of the vehicle in a localscript is a better idea, anyways thanks for correcting me.

All right thank you I’ll try this this when I can.

Its easy, put your code on script and go to RunContext and set it to Client

Thank you but I’ve already solved this a year ago.

I’ve moved everything locally and it worked.