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

How do you rotate a player along the x and z axis?

Title says all.

I've tried using BodyGyro and it worked to some extent, but it doesn't quite rotate to the angle I want it to.

Code I've tried:

local Players = game:GetService("Players")


Players.PlayerAdded:Connect(function(player)
	repeat wait() until player.Character
	local character = player.Character
	local humanoid = player.Character:WaitForChild("Humanoid")
	humanoid.AutoRotate = false

	local bodyGyro = Instance.new("BodyGyro", player.Character.HumanoidRootPart)
	bodyGyro.MaxTorque = Vector3.new(999999,999999,999999)
	bodyGyro.P = 99999
	bodyGyro.D = 0
	bodyGyro.CFrame = CFrame.Angles(math.rad(45),0,0)
	humanoid.AutoRotate = true
end)

But the player only rotates 31.58 degrees, not the full 45.

1 answer

Try

character.HumanoidRootPart.CFrame =  CFrame.new(x, y, z) * CFrame.Angles(0, math.rad(90), math.rad(180))

the 0, 90, 180 are random values, change them

2 comments

0

Humanoid.CFrame?

0

I don’t think you can change the rotation via CFrame like that, since roblox automatically tries to straighten the player.

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