How can i make this script run faster?

RunService.RenderStepped:Connect(function()
local objectspace = HumanoidRootPart.CFrame:toObjectSpace(Camera.CFrame).LookVector
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * Angle(zero, -math.asin(objectspace.X), zero)
end)

This scripts goal is to replace Humanoid.AutoRotate it does it well but i want it to run faster.
Any Help Appreciated!

4 Likes

Maybe Heartbeat instead RenderStepped?

4 Likes

I tried this but it’s not any faster :confused:

3 Likes

Wait, I test it in my studio to test. I will edit this message right now!

It’s localscript? Yes it’s localscript because renderstepped

3 Likes

Yeah the problem is if I turn my camera too fast it looks weird

2 Likes

Maybe:

Camera.Changed:Connect(function()
	local objectspace = HumanoidRootPart.CFrame:toObjectSpace(Camera.CFrame).LookVector
	HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * Angle(zero, -math.asin(objectspace.X), zero)
end)
2 Likes

Anything else a little bit faster than Camera.Changed? because the character still can’t keep up with the camera.

2 Likes
while true do
	local objectspace = HumanoidRootPart.CFrame:toObjectSpace(Camera.CFrame).LookVector
	HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * Angle(zero, -math.asin(objectspace.X), zero)
	Camera.Changed:Wait()
end

I don’t know what can be faster

3 Likes

Ok so, I found the solution, I just decided to Lerp the HumanoidRootPart to the camera lookvector but thanks for the help @Staric14

3 Likes

There is no way to make this run ““faster””. RenderStepped and all subsequent RunService functions fire whenever a new frame has been rendered. What you need to do is set a speed variable for how fast the character rotates, and adjust it to the DeltaTime of each frame.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.