(Bad English Warning)
I made aiming animation and script that makes head move up and down using motor6D following mouse
The problem is that motor6D breaks the animation
How it must look
And how it looks
UIS.InputBegan:Connect(function(keyCode,isTyping)
if isTyping then
return
end
if keyCode.UserInputType == Enum.UserInputType.MouseButton1 then
local breaking=false
local cancel
combatEvent:FireServer(true)
cancel = UIS.InputEnded:Connect(function(input,isTyping)
if isTyping then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
cancel:Disconnect()
breaking=true
Root.Parent.Torso.Neck.C1 = CFrame.new()
Root.Parent.Torso.Neck.C0 = CFrame.new(0,1.5,0) * CFrame.Angles(0,0,0)
combatEvent:FireServer(false)
end
end)
local loop
loop=game:GetService("RunService").RenderStepped:Connect(function()
if not breaking then
Root.Parent.Torso.Neck.C1 = CFrame.new()
Root.Parent.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), 0,0)
Root.Parent.Torso.Neck.CurrentAngle = 0
local RootPos, MousePos = Root.Position, Mouse.Hit.Position
Root.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z))
end
end)
end
end)
I am only 14 years old and Trigonometry is so hard for me
Script that rotates the head I took from other topic. I alredy tried changing C0 to C1 but it breaks the animation even more.
Thank you for replies