What can I do to make the character look in the direction the camera is looking when doing the animation? I tried to put the CFrame lookvector of the camera to the HumanoidRootPart, But apparently it didn’t work
local localplayer = game:GetService("Players").LocalPlayer
local character = localplayer.Character
local root = character:WaitForChild("HumanoidRootPart")
local gyro = Instance.new("BodyGyro", root)
gyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9)
while wait() do
gyro.CFrame = workspace.CurrentCamera.CFrame
end
local Game = game
local Workspace = workspace
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Workspace.CurrentCamera
local function OnRenderStep()
Character:PivotTo(CFrame.new(Character:GetPivot().Position) * Camera.CFrame.Rotation)
end
RunService.RenderStepped:Connect(OnRenderStep)
Compatible with both R6 and R15 avatar types. You can set the camera’s type to ‘Scriptable’, then run the code within a loop which matches the length of the animation’s duration and then set the camera’s type back to ‘Custom’.