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?
Here is the video:
Looks to me you have a long, non-yielding loop somewhere that’s freezing the client.
Example:
for i = 1, 100000000 do
print("Hello World!")
end
This will completely freeze your game until the script times out (and stops executing).
We’re happy to help, but you simply haven’t given us enough information. Consider posting your entire script, and not just snippets.
I dont think so, because when i commented this line, the lag wasnt there:
script.Parent.Occupant.Parent.HumanoidRootPart.RotVelocity=rotVelocity
You should use RunService.Stepped to set RotVelocity because it runs immediately before physics. There should be no reason for lag to occur from velocities. Speed does not effect lag, the number of physics calculations does which velocities do not effect.
It’s unclear what you mean by lag. What is your client fps when you experience the issue? Is the lag only occurring for the target part?
Pls look on the video, it just freeze.
And I use this for running the function
game:GetService("RunService").Stepped:Connect(function ()