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

What am I doing wrong with this Vector3 math?

Asked by
drew1017 330 Moderation Voter
9 years ago
char:MoveTo((Lobby.Position * Vector3.new(math.random(-2, 2), 0, math.random(-2, 2))))

Without the * Vector3.new(stuff), this works just fine, teleporting the char to Lobby. But with it, it teleports the char to the middle of the map instead, near Vector3 0,0,0. I've used Vector3 before and i'm pretty sure multiplying a position by a vector3 means ''position plus these coordinates'', not ignoring the position entirely. I'm a bit rusty, so what am I doing wrong?

2 answers

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

Vector3s can be added normally. CFrames are multiplied to perform a translation because they are matrices and not coordinates.

Ad
Log in to vote
0
Answered by
xApRix 25
9 years ago
char:MoveTo((Lobby.Position + Vector3.new(math.random(-2, 2), 0, math.random(-2, 2))))

This should work. :)

Answer this question