How to make the rotation of the head relative to the magnitude of head camera

I’m having trouble reading my script, I can’t seem to figure out where to put the magnitude, everywhere I try it yields an error stating that I tried to perform arithmetic on userdata. This is my script: (The comment is the magnitude)

local Char = script.Parent

local Humanoid = Char:WaitForChild("Humanoid")

local Camera = workspace.CurrentCamera

Char:WaitForChild("Head")

local Neck = Char:FindFirstChild("Head"):WaitForChild("Neck")

local Waist = Char:FindFirstChild("UpperTorso"):WaitForChild("Waist")

game:GetService("RunService").RenderStepped:Connect(function()

game.ReplicatedStorage.Head:FireServer(CFrame.new(0,.8,0) * CFrame.Angles(math.atan2(Camera.CFrame.lookVector.Y, math.sqrt((Camera.CFrame.lookVector.X^2)+(Camera.CFrame.lookVector.Z^2)))/1.5, math.pi * 2,0),CFrame.new(0,0,0) * CFrame.Angles(math.atan2(Camera.CFrame.lookVector.Y, math.sqrt((Camera.CFrame.lookVector.X^2)+(Camera.CFrame.lookVector.Z^2)))/3.5,math.pi * 2,0))

end)

--(game.Workspace.CurrentCamera.CFrame.p-game.Players.LocalPlayer.Character.Head.Position).magnitude

  • List item
    (Serverscritp)
    >     >     >     >     >     >     >     > local Remote = game.ReplicatedStorage.Head
    >     >     >     >     >     >     >     > Remote.OnServerEvent:Connect(function(Player, c0,c01)
    >     >     >     >     >     >     >     >     if not Player.Character then return end
    >     >     >     >     >     >     >     >     if not Player.Character:FindFirstChild("Head") or not Player.Character.Head:FindFirstChild("Neck") then return end
    >     >     >     >     >     >     >     >     local b = TweenInfo.new(.5,Enum.EasingStyle.Quint)
    >     >     >     >     >     >     >     >     local a = {
    >     >     >     >     >     >     >     >         C0 = c0
    >     >     >     >     >     >     >     >     }
    >     >     >     >     >     >     >     >     game:GetService("TweenService"):Create(Player.Character.Head.Neck,b,a):Play()
    >     >     >     >     >     >     >     >     local b = TweenInfo.new(.5,Enum.EasingStyle.Quint)
    >     >     >     >     >     >     >     >     local a = {
    >     >     >     >     >     >     >     >         C0 = c01
    >     >     >     >     >     >     >     >     }
    >     >     >     >     >     >     >     >     game:GetService("TweenService"):Create(Player.Character.UpperTorso.Waist,b,a):Play()
    >     >     >     >     >     >     >     > end)
1 Like

Don’t reply to bump your topic, that’s against the TOS of the devforum.

Also, please simplify

CFrame.new(0,.8,0) * CFrame.Angles(math.atan2(Camera.CFrame.lookVector.Y, math.sqrt((Camera.CFrame.lookVector.X^2)+(Camera.CFrame.lookVector.Z^2)))/1.5, math.pi * 2,0),CFrame.new(0,0,0) * CFrame.Angles(math.atan2(Camera.CFrame.lookVector.Y, math.sqrt((Camera.CFrame.lookVector.X^2)+(Camera.CFrame.lookVector.Z^2)))/3.5,math.pi * 2,0)

into variables so we can spot errors easier.

I can’t I explicitcly stated already that I can’t figue out which is which, I don’t need fix for the error, I just need to figure out which is which. It’s very hard to read and that’s where I’m dependant onyou, the comunity to help me find out which numbers ihave to use to divide by the magnitude

Just separate the values inside into variables, not do any additional math for now. The errors are causing issues, and we need to find them.

For example, CFrame.new(0,.8,0) can be it’s own variable.

Please note the DevForum is not here to do the work for you, #help-and-feedback:scripting-support is for general code issues or questions.

I know that, I do, the problem is if I use variables it will overcomplicate this a bunch, all I need is to figure out the numbers that I need to divide by my magnitude so that I can make rotation power relative to head camera magnitude. There is no error to fix, there is no error at all. All I need to figure out is which numbers to divide by head camera magnitude