Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[Solved] How do I make this rotating CFrame thing less laggy?

So I'm making a small unrealistic plane, but whenever I tell the script to orientate the plane, it's really laggy, this is what I mean:

https://youtu.be/BaL5R86oCqk

Also, this is the code I use to orientate it:

frame.CFrame = CFrame.new(frame.Position,script.Parent.MouseVectorP.Value)

3 comments

0

Also, I used a while loop to update it.

0

You need way more code than just that one line

0

Don't use a while loop to update it, instead use RunService events

1 answer

✓ Accepted answer

Loops cause a lot of lag if you don't add a wait(). The thing is, wait() can cause lag standalone if you don't add a number, like wait(.1). You can add a wait() but you can also do an event.

script.Parent.MouseVectorP:GetPropertyChangedSignal("Value"):Connect(function()
	frame.CFrame = CFrame.new(frame.Position, script.Parent.MouseVectorP.Value)
	wait(.01)
end)

Above we have an event that fires every time the value of MouseVectorP changes, and once it fires we orientate the frame accordingly.

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.