The first thing I tried was
part.Position.X = math.floor(part.Position/3+0.5)*3
but then I did some research and realized you cant do that. but all pages I could find on this weren't on performing math on it.
now I'm stuck because even if I wanted to slide it with vector3 I dont know how I would do a math.floor with that
Output: (Vector3 expected, got number)
and lol sorry asking a lot of questions today, but they've all been really helpful
Edit:
Edit: This is in a while true loop going to the players mouse and then applying this to make a grid placing system of every 3 pixels in each direction
Sub-properties under the parent Properties like:
BasePart.Position.X
BasePart.BrickColor.r
or even:
BasePart.CFrame.Position
are read-only, or immutable, properties. They are properties that can't be changed by setting it to some int/number. You need to directly set the parent property with the required data type.
So setting Position would require a Vector3:
BasePart.Position = Vector3.new(0,0,0) --sets basepart to coordinate 0,0,0
Performing 'math' on the current position of the part could be done by using the addition, +
, operator as an example:
BasePart.Position = BasePart.Position + Vector3.new(0, 10, 0) --would move the part's current position 10 studs up
There is so much more you could do with positioning in CFrames that can also include rotational math. It's a beast of it's own but is worth learning.
Edit:
Calculate position values beforehand then construct a new Vector3 with those values in it:
local offset = 10 local random = math.random(1, offset) --would get a number between 1-10 local vector3 = Vector3.new(0, random, 0) BasePart.Position = BasePart.Position + vector3
This is an example. This only runs the code once until you run it again so it should move the part upwards depending on the random number returned on line 03.
--instead of using the vector3 values, i'd use CFrame.new part.CFrame = part.CFrame + Vector3.new(0,10,0)