Script:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
repeat wait() until char
local HRP = char.HumanoidRootPart
local checkpoint = FindCheckpoint(player.leaderstats.Stage.Value)
HRP.CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,3,0))
HRP.Orientation = Vector3.new(checkpoint.Orientation)
end)
end)
Your topic name and code have nothing in common. Your code, is for finding stage number. Your topic, is for rotating the player. And, there is ABSOLUTELY NO CONTEXT! Please, CLARIFY!!
Well I didnt know how to state it
You’re rotating the HumanoidRootPart instead of rotating the whole model. Try this instead:
char:PivotTo(CFrame.new(checkpoint.Position + Vector3.new(0,3,0)) * checkpoint.CFrame.Rotation)
i am changing the orientation of the HRP only
That’s exactly what I’m trying to point out. You can’t just rotate the HumanoidRootPart. Rotate the model instead!
wat does pivotto mean? i was reading the documentation on it but idk
It changes the model’s CFrame to the CFrame specified in the parenthesis.
why do we * (multiply) the rotation and why not use orientation and not cframe.rotation
The multiplication operator combines the CFrames. Look at the documentation for more info. Remember, CFrame combination is not always communative, meaning it isn’t the same forwards to backwards. Orientation only rotates the part. Below is an attached example:
Character.HumanoidRootPart.Orientation = Vector3.new(0, 45, 0)
:
Character:PivotTo(CFrame.new(Character.WorldPivot * CFrame.Angles(0, math.rad(45), 0)))
:
The main difference is that for the top image, only the HumanoidRootPart rotates.
Make sure to use math.rad()
for CFrame.Angles
, or it won’t rotate correctly!
We CAN use Orientation, but we’ll have to convert it with math.rad()
, and is a more timely process:
CFrame.Angles(math.rad(Character.HumanoidRootPart.Orientation.X), math.rad(Character.HumanoidRootPart.Orientation.Y), math.rad(Character.HumanoidRootPart.Orientation.Z))