Can someone simplify this math please

YouCanNeverSeeTheSun (1).rbxl (61.2 KB)

local lookVector = -camera.CFrame.LookVector
lookVector = Vector3.new(lookVector.X, 0, lookVector.Z)
lookVector = (CFrame.new(part.Position, part.Position + lookVector) * CFrame.Angles(math.sin(math.rad(math.round(handle.Position.X.Scale*100))), 0, 0)).LookVector

Thanks!

Can’t really simplify this without knowing what it’s supposed to do.

local lookVector = -camera.CFrame.LookVector
lookVector = Vector3.new(lookVector.X, 0, lookVector.Z)
lookVector = (
	CFrame.new(
		part.Position,
		part.Position + lookVector) * 
	CFrame.Angles(
		math.sin(
			math.rad(
				math.round(handle.Position.X.Scale * 100))), 
		0, 
		0)
	).LookVector

Here’s a start:

local lookVector = -camera.CFrame.LookVector
lookVector = (CFrame.new(Vector3.new(0,0,0), Vector3.new(lookVector.X, 0, lookVector.Z)) * CFrame.Angles(math.sin(math.rad(math.round(handle.Position.X.Scale*100))), 0, 0)).LookVector

What it’s supposed to do:
The sun is supposed to always follow the player’s camera, but behind. So in theory the player can never see shadows. But if the player looks up, it would be night time, so that’s why there’s a slider for the sun height :smiley:

local height = math.sin(math.rad(math.round((1-handle.Position.Y.Scale)*100)))
	
local lookVector = -camera.CFrame.LookVector
lookVector = (CFrame.new( Vector3.new(0,0,0), Vector3.new(lookVector.X, 0, lookVector.Z) ) * CFrame.Angles(height, 0, 0)).LookVector

Any good way to simplify the following?

CFrame.new(Vector3.new(0,0,0), Vector3.new(lookVector.X, 0, lookVector.Z))

Thanks!