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

Issue with Changing the Position of a Part - is Vector3 broken?

Asked by 6 years ago
Edited 6 years ago

I'm trying to change the position of block "er" in "row" using some constants c1 and c2 that vary for each block. This code is run 121 times for 121 different blocks with varying c1 and c2 values. You'd think this would be really simple but

row.er.Position = Vector3.new(row.er.Position.X, (1+c1+c2)/2, row.er.Position.Z)
print(c1, c2, (1+c1+c2)/2)
print(row.er.Position)

prints:

158.50003051758 152.50003051758 156.00003051758
36, 162.000015, -2

for a certain iteration of the code. Over all 121 times the code is run, the position is not properly assigned 4 times. All 117 other calls position the block correctly.

What gives? All this code should be doing is v = <x,y,z> print v.y == y - how is that not a tautology?

0
I also (earlier) had an issue where: k = Vector3.new(part.Position.X, f(some numbers), part.Position.Z) part.Position = k print(part.Position, k) would print two different vectors coolguy54321344 0 — 6y
0
For all we know it's a standard floating point error. Prove that there are big differences. In any case you might be better off cframing. cabbler 1942 — 6y
0
@cabbler edited with better print statements, my bad. I really hope that 156 doesn't turn into 162 due to floating point errors, I can't imagine a game being that badly coded. coolguy54321344 0 — 6y
0
Yeah try cframing. cabbler 1942 — 6y

Answer this question