Tweening The Orientation of a Humanoid?

Hey guys,

I’ve looked around the forum, but am unable to
find any info on tweening the orientation of a humanoid.

Any links/code snippets will be much appreciated. Thanks.

Firstly, this is kinda i nthe wrong category since this is #development-discussion , move it to #help-and-feedback:scripting-support.

Secondly, by Tweening the Humanoid Orientation, do you mean the orientation of the Torso/HumanoidRootPart?

1 Like

Thanks for the reply,

Moved.

Yes, I’m wanting to tween the humanoidrootpart

1 Like

That’s not that difficult, there’s a few steps to do that

  1. Create variables for TweenService, TweenInfo
  2. Reference the HumanoidRootPart
  3. Create the Tween and play it

As in exanmple, we’ll say you’re wanting to do it for when you click on a part

local ts = game:GetService("TweenService")
local info = TweenInfo.new() -- For this I'll use the default TweenInfo

local part = script.Parent

part.ClickDetector.MouseClick:Connect(function(plr) --This event returns who clicked the part
	local char = plr.Character
	
	if char and char.Humanoid.Health > 0 then --Check if the Character exists and is alive
		local root = char.HumanoidRootPart
		
		local tween = ts:Create(root,info,{Orientation = Vector3.new(179,0,0)}) --Creates a tween that'll rotate the rootpart to 179 in the x
		
		tween:Play()
	end
end)

This is how I would do it, this is roughly the steps you want to carry out when using TweenService. To make it work for whatever you want, just change the way the script is done, just keeping a few things the same like making variables for TweenInfo and TweenService and making a tween and playing it

Great, Thanks.
I’ve tested the the code, however the following is causing issues.

I tried the following in a click detector function

local ts = game:GetService("TweenService")
local info = TweenInfo.new() -- For this I'll use the default TweenInfo

local root = game.Players.LocalPlayer.Character.HumanoidRootPart

local tween = ts:Create(root,info,{Orientation = Vector3.new(0,179,0)}) --Creates a tween that'll rotate the rootpart to 179 in the x

tween:Play()

The humanoid immediately faces the ground and rotates continuously, and remains facing the ground when moving via WASD.

any ideas?

The above code works flawlessly on a part, just acting weird on the HumanoidRootPart.

I think you may’ve forgot to put the code in a Mouseclick event if you’re referring to it happening immediately, in terms of the other thing, I’m not sure if it’s the AutoRotate messing it up

I tried setting AutoRotate to false

game.Players.LocalPlayer.Character.Humanoid.AutoRotate = false

same thing with facing the ground, is it possible to tween the Orientation via CFrame on the HumanoidRootPart?

You can, instead of Orientation = Vector3.new() Just do CFrame = root.CFrame * CFrame.Angles(math.rad(179),0,0)

local ts = game:GetService("TweenService")
local info = TweenInfo.new() -- For this I'll use the default TweenInfo

local root = game.Players.LocalPlayer.Character.HumanoidRootPart

local goal = {}
goal.CFrame = root.CFrame * CFrame.Angles(179,0,0)

local tween = ts:Create(root,info,goal) --Creates a tween that'll rotate the rootpart to 179 in the x

tween:Play()

This should work as well but in terms of the angle, you’ll have to switch from 1 of those 3 if it’s not the one you wanted. If there’s an error relating to CFrame.Angles, you’ll have to put 179 in a math.rad()

2 Likes

Aweome, Thank you.

I’ll give it a try.

1 Like

Works perfectly. Thank you very much for you help :smiley:

I’m glad it worked out for you in the end! If you have anymore issues don’t be afraid to make another post!