Hi i’d need help on how to add 2 vector 3 values :
local TablePos = {
Vector3.new(10, 3, -17),
Vector3.new(17.2, 3, -17),
Vector3.new(20.6, 8.6, -10),
Vector3.new(20.6, 8.6, 10),
Vector3.new(20.6, 1.2, 2),
Vector3.new(17.2, 3, 17.4),
Vector3.new(11.8, 3, 17.4),
Vector3.new(10, -3, 6),
}
script.Parent.Position = Vector3.new(????) + TablePos[math.random(1,8)]
Basically I want the original Vector3 value of the part to get added one of the values in the table.
It is simple, just do:
script.Parent.Position = script.Parent.Position + TablePos[math.random(1,8)]
If you want you can do this too:
script.Parent.Position += TablePos[math.random(1,8)]
And if you want the game to automatically get the table length you can do this:
script.Parent.Position += TablePos[math.random(1,#TablePos)]
4 Likes
You have to store the original vector3 in a variable and use it later.
-- example
local originalVector3 = script.Parent.Position
local TablePos = {
Vector3.new(10, 3, -17),
Vector3.new(17.2, 3, -17),
Vector3.new(20.6, 8.6, -10),
Vector3.new(20.6, 8.6, 10),
Vector3.new(20.6, 1.2, 2),
Vector3.new(17.2, 3, 17.4),
Vector3.new(11.8, 3, 17.4),
Vector3.new(10, -3, 6),
}
script.Parent.Position = originalVector3 + TablePos[math.random(1,8)]
or do what @DanilochRBX did, if that works for you
2 Likes
Oh thanks yea that was easy XD
2 Likes