So here is my script it controls all things for now like animations and the aiming. The aiming stuff is at the end of the script. I was wondering if i can make it so i can rotate root but not rotate the legs. Here is a gif of the problem. Gyazo Gif
wait()
local WA = Instance.new("Animation")
local IA = Instance.new("Animation")
local SA = Instance.new("Animation")
local AA = Instance.new("Animation")
local JA = Instance.new("Animation")
JA.AnimationId = "rbxassetid://2722201562"
AA.AnimationId = "rbxassetid://2719070294"
SA.AnimationId = "rbxassetid://2719102937"
WA.AnimationId = "rbxassetid://2719079532"
IA.AnimationId = "rbxassetid://2719075199"
local humanoid = script.Parent.Humanoid
local AimAnimation = humanoid:LoadAnimation(AA)
local WalkAnimation = humanoid:LoadAnimation(WA)
local IdleAnimation = humanoid:LoadAnimation(IA)
local SprintAnimation = humanoid:LoadAnimation(SA)
local IsIdle = false
local UserInputService = game:GetService("UserInputService")
local Camera = game.Workspace.CurrentCamera
local Char = script.Parent
local Aiming = false
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
humanoid.Running:Connect(function(s)
if s > 1 then
IdleAnimation:Stop()
WalkAnimation:Play()
IsIdle = false
else
WalkAnimation:Stop()
IdleAnimation:Play()
IsIdle = true
end
end)
local XOffset = 1
local Y = 1
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.LeftShift and IsIdle == false then
SprintAnimation:Play()
humanoid.WalkSpeed = 20
end
local inputType = inputObject.UserInputType
if inputType == Enum.UserInputType.MouseButton2 then
Aiming = true
humanoid.WalkSpeed = 0
AimAnimation:Play()
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
SprintAnimation:Stop()
humanoid.WalkSpeed = 3
end
local inputType = inputObject.UserInputType
if inputType == Enum.UserInputType.MouseButton2 then
Aiming = false
humanoid.WalkSpeed = 3
AimAnimation:Stop()
end
if inputObject.KeyCode == Enum.KeyCode.Space then
humanoid.FallingDown:Connect(function(isActive)
end)
end
end)
UserInputService.InputChanged:connect(function(IO)
if IO.UserInputType == Enum.UserInputType.MouseMovement then
X = IO.Delta.X/150
if Y-IO.Delta.Y/150 < 1 and IO.Delta.Y < 0 then
Y = Y-IO.Delta.Y/150
elseif Y-IO.Delta.Y/150 > -1 and IO.Delta.Y > 0 then
Y = Y-IO.Delta.Y/150
end
if Y > 1 then
Y = 1
elseif Y < -1 then
Y = -1
end
end
end)
game["Run Service"].RenderStepped:connect(function()
if Aiming == true then
Camera.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(Vector3.new( 0,2.5,.25)+Char.Humanoid.CameraOffset)*CFrame.fromEulerAnglesXYZ(Y,0,0)*CFrame.new(XOffset,0,6)
Char.HumanoidRootPart.CFrame = Char.HumanoidRootPart.CFrame * CFrame.fromEulerAnglesXYZ(0,-X,0)
Char.LowerTorso.Root.C0 = CFrame.Angles(math.rad(Camera.CFrame.lookVector.Y*90),0,0)
X = 0
end
end)
i cant use Char.UpperTorso.Waist because it aims at a weird angle and i dont know how to work with that.

2 comments
Have you tried using HumanoidRootPart?
yes i have and it doesnt work very well or i was doing something wrong