Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
H3kken -4
4 years ago
Edited 4 years ago

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)

0
Also, I used a while loop to update it. H3kken -4 — 4y
0
You need way more code than just that one line User#24403 69 — 4y
0
Don't use a while loop to update it, instead use RunService events User#24403 69 — 4y

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
4 years ago

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.

0
Thanks! H3kken -4 — 4y
Ad

Answer this question