CFrame.Angles problem

Hi, I am trying to create a boid system
however, the output said: “attempt to index nil with “rad””
code:

goldenRatio = (1 + math.sqrt(5)) / 2;
local elapsetime = 0
local rnuser = game:GetService("RunService")
rnuser.Stepped:Connect(function(time,i)
	elapsetime  = elapsetime + i
local mathrandom = math.random(-1,1)
	local t = elapsetime / 0.01
	local t2 = (elapsetime + 0.1) / 0.01

	local dst = t / (360)
	local angle = goldenRatio * math.pi * 1/100 * t
	
	local angleafter = goldenRatio * math.pi * 1/100 * t2

	local x = 40 * math.cos(angle) * 0.1
	local z = 40 * math.sin(angle) * 0.1
	local xa = 40 * math.cos(angleafter) * 0.1
	local za = 40 * math.sin(angleafter) * 0.1
	print("distance"..dst)
	print(x * 0.1)
	print(z * 0.1)
	local math = math.noise(x,1,z)
	script.Parent.CFrame = script.Parent.Parent.CFrame * CFrame.new(x,0,z)
	script.Parent.CFrame = CFrame.lookAt(script.Parent.Position,(script.Parent.Parent.CFrame * CFrame.new(xa,0,za).Position)) * CFrame.Angles(math.rad(0),math.rad(180),math.rad(0))
	
end)

Why didn’t it recognize the thing as math.rad? did I do something wrong?

1 Like

i think you don’t need to put math.rad for 0 degrees because the radiance of 0 degree is 0 itself

thx for trying to help but i already found the problem. turns out i had a variable i made named math too and the compiler got confused

1 Like