I have an NPC dialogue system (local script), I am trying to make the NPC turn to the player when a conversation starts, I currently have this code but the tween doesn’t work no matter what I do.
function torso_turn(char, subject) -- subject: the NPC's character
local torso = subject:FindFirstChild("Torso")
local root = char.HumanoidRootPart
if torso then
local new_cframe = CFrame.new(torso.Position, Vector3.new(root.Position.X, torso.Position.Y, root.Position.Z))
local tween = TS:Create(torso,
TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut),
{
CFrame = new_cframe
}
)
tween:Play()
-- the CFrame \/, it works if I run this line but I want it smooth :(
-- torso.CFrame = CFrame.new(torso.Position, Vector3.new(root.Position.X, torso.Position.Y, root.Position.Z))
end
end
I have tried setting it to other CFrames but those don’t work either, this tween for some reason just refuses to tween CFrames, it works just fine if you change orientation/position of the torso via tween.
Have you tried tweening the HumanoidRootPart of the NPC rather than the torso? Typically when I’m dealing with character orientation, setting CFrame by the HumanoidRootPart seems to work better than torso.
I believe that what @Chark_Proto suggested is the technical way to set an index, but ROBLOX made our lives a little easier by not requiring it when writing a property table for Tween Service.