Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"attempt to perform arithmetic on field '?' (a nil value)" Error help?

Asked by 10 years ago

This is my function

function loop (frames)
    for i = 1,frames do
    whead.C0 = CFrame.Angles(math.rad(dh[1]/frames + h[1]),math.rad(dh[2]/frames +h[2]),math.rad(dh[3]/frames +h[3]))
end
end

loop(10)

I get this error on line 4 "attempt to perform arithmetic on field '?' (a nil value)" dh and h are tables with 3 number values( Hence the brackets [] ), frames is also a number value.

dh and h are originally 0 dh is the difference, h is the current rotation the empty dh and h are passed through a function giving it a value. But it they both start off as

h = {}
dh = {}
--then they go through this function which sets the variable in the table's value

function differences(new,current,difference)
    difference = new-current
end
--so it would be
differences(new**(which doesn't pertain to this problem)**,h[1],dh[] )
0
What are dh and h? Please provide additional information or additional code for us to get a better overview of the script. The function also has no end. Ravenshield 180 — 10y
0
I specifically said what dh and h are. They are number real number values... Orlando777 315 — 10y
0
Insisting that what you're doing is correct and supplying no other information, yet still asking for help because you actually are doing something wrong, is not going to result in help. 1waffle1 2908 — 10y
0
What else is there to supply? frame is 10, and lets say dh and h's numbers in the table are 1,2,3. so it should calculate 1/10 +1 = 1.1 and so on. Orlando777 315 — 10y
View all comments (3 more)
0
And I didn't insist I'm correct. Obviously I'm not since it isn't working. Orlando777 315 — 10y
0
If you could just take the 10 seconds to post the code where dh and h are defined, we can actually troubleshoot your code in our own Studio. Clearly something is inexistant or undefined, as dummy-values for dh, h and frames works just fine. Ravenshield 180 — 10y
0
BTW, I took what was in that math.rad and printed it. It didn't give me nil, that's what I find strange. Orlando777 315 — 10y

Answer this question