Hi,
I need to set RotVelocity of part, but it lag, is there any way to do this without the lag?
What are you trying to accomplish? And can you define “lag” in this scenario? What exactly is happening?
There are many different ways to apply rotation velocity, but it’s better to first understand what your overall objective is.
I will be happy to give you video, but I have too slow internet. But the lag freeze whole client. And after about 0,5 sec, the client is normal again, so classic lag.
To set parts rotation velocity, so it will rotate around its y.
You could try using the BodyForce, BodyAngularVelocity, to apply rotational velocity.
Keep in mind if you want to delete it after some time wait and then :Destroy() it or use Debris.
I tried, but i got problem, that it is controling the part in all axis, but body rotVelocity is cotroling it just in 1 axis
What did you give for it’s AngularVelocity?
players humanoid, but i use it in car
I mean the Vector3 which you have for the BodyAngularVelocity’s AngularVelocity.
local rotVelocity = script.Parent.Occupant.Parent.HumanoidRootPart.CFrame:vectorToWorldSpace(Vector3.new(script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity.X+turnSpeed2.X,turnSpeed2.Y,script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity.Z+turnSpeed2.Z))
script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity=rotVelocity
I thought you said you were using a BodyAngularVelocity?
Also that looks to be a big rotVelocity, the more Velocity the more lag.
OK, so can i edit this to be without the lag?
On what Axis and how much force do you want to apply to their HumanoidRootPart?
On y axit, but from object so it can change, when i do it in world space. And force enough to rotate the car, but less as it can o other axis, because than the car dont fall on terrain, and just stay in its rotation.
BodyAngularVelocity is in World space so you won’t need to worry about that.
I’d apply a Velocity of perhaps 5 (Vector3.new(0,5,0)
), a P of around 5 (add it higher for more power!) and a MaxTorque of math.huge (why not).
Here’s what I mean in action:
local Debris = game:GetService("Debris")
local occupant = script.Parent.Occupant.Parent
local BAV = Instance.new("BodyAngularVelocity")
BAV.AngularVelocity = Vector3.new(0,5,0)
BAV.P = 5
BAV.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
BAV.Parent = occupant.HumanoidRootPart
Debris:AddItem(BAV, 2) --after 2 seconds, stop the velocity
I think, you didnt understand me, because i define the velocity in object space. And I need to let the car free rotate on diferent axis.
Can you give that video to help me understand how to solve your problem?
Setting the RotVelocity of a part, even if you do it hundreds of times a second, should not produce any noticeable lag, stuttering or freezing at all.
Which means one of three things
-
There is other code, maybe a malicious script from an infected free model or plugin, in your game causing the problem, or there is otherwise something wrong with your code.
-
There is something wrong with your computer.
-
There is a bug in the roblox engine, and you should file a bug report.
I tried the first option, but when i commented the line, it works. The second option is impossible, because i have extremly fast computer. The third option can be, but i saw this line in roblox race map, and it works there without the lag.
Could you paste your code here for us?
local turnSpeed2 = script.Parent.CFrame:VectorToWorldSpace(Vector3.new(0,turnSpeed,0))
local rotVelocity = script.Parent.Occupant.Parent.HumanoidRootPart.CFrame:vectorToWorldSpace(Vector3.new(script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity.X+turnSpeed2.X,turnSpeed2.Y,script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity.Z+turnSpeed2.Z))
script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity=rotVelocity
Enough or you need more code?