What Does This Line Of Code Mean?

So I learned today how to make the torso look at the mouse. I needed to learn trigonometry and more about CFrame to know how to do this and I also had to learn how to use Motor6Ds.

I used a YouTube video to try and figure this out but kind of struggled a little bit with a certain line.

Anyway here is the script:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local runservice = game:GetService("RunService")

local upperTorso = character:FindFirstChild("UpperTorso") or character:WaitForChild("UpperTorso")
local waist = upperTorso:FindFirstChild("Waist")

local orgin = waist.C0

runservice.RenderStepped:Connect(function()
	
	local point = mouse.Hit.p
	
	local dist = (upperTorso.CFrame.p - point).Magnitude
	local diff = upperTorso.CFrame.Y - point.Y
	
	waist.C0 = orgin * CFrame.Angles(-(math.asin(diff / dist)), (((upperTorso.Position - point).Unit):Cross(upperTorso.CFrame.LookVector)).Y, 0)
	
end)

Basically I just need someone to help me breakdown this line of code:

waist.C0 = orgin * CFrame.Angles(-(math.asin(diff / dist)), (((upperTorso.Position - point).Unit):Cross(upperTorso.CFrame.LookVector)).Y, 0)

Everything is working fine I just don’t want to work with something unless I know about it.


3 Likes

i think these r da parts u r strugglin with :slight_smile:
point me out if im wrong some where

i havent learned about vector stuff in school as well

1 Like