Lets say I have a function that runs through conditions, and if those conditions are met, it will return a value to be printed. In this case it is a function that checks the angle between two objects, like so:
(It returns nil. What's wrong with the script and how do I use return properly)?
function angleInFront()
local lookVector = script.Parent.CFrame.LookVector
local otherVector
local angleBetween
for i,v in pairs(workspace:GetChildren) do
if v.Name == "Part" then -- and other conditions
otherVector = (v.Position - script.Parent.Position).Unit
angleBetween = math.deg(math.acos(lookVector:Dot(otherVector)))
if angleBetween < 90 then -- 90 degrees on either side from the front
return angleBetween
end
end
end
end
angleInFront()
print angleBetween

1 comment
This does help, thank you.