Hello, I'm NYDynamics and today I have attempted to script a Bezier curve Function. For some reason it returns in the output...
0,0,0(x3) nil
Even though they have positions it returns 0,0,0??? It would be great if someone could help! My code is...
local P0 = workspace.P0 local P1 = workspace.P1 local P2 = workspace.P2 local tan = (P0.Position - P2.Position).magnitude function lerp(a,b,c) return print(a + (b-a) * c) end function quadBezier(tan,P0,P1,P2) local L1 = lerp(Vector3.new(P0),Vector3.new(P1),tan) local L2 = lerp(Vector3.new(P1),Vector3.new(P2),tan) local quad = lerp(Vector3.new(L1),Vector3.new(L2),tan) return print(quad) end quadBezier(tan,P0,P1,P2)
local P0 = workspace.P0 local P1 = workspace.P1 local P2 = workspace.P2 local tan = (P0.Position - P2.Position).magnitude function lerp(a,b,c) return a + (b-a) * c end function quadBezier(tan,P0,P1,P2) local L1 = lerp(Vector3.new(P0),Vector3.new(P1),tan) local L2 = lerp(Vector3.new(P1),Vector3.new(P2),tan) local quad = lerp(Vector3.new(L1),Vector3.new(L2),tan) return quad end print(quadBezier(tan,P0,P1,P2))
The problem is that you're telling the program to return print(...)
, which will return the value the print function returns, which is nil
. What you want is just return whatever
^.