How to make my placement system work on a 100 plot if grid is changed?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

So.I suck at math lol. I want my system to work on a plot thats size is 100 studs.

  1. What is the issue? Include screenshots / videos if possible!

My issue is that it goes out of the plots boundaries when you change the grid size to 2 or higer. I basically want it to still work on a 100 studs plot if thats possible

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried looking at some tutorials and other placement modules to see how they fix it. But couldnt find anything that would help me.

I suck at math once again so im not really sure if this even is possible. Any help would be really cool ;D

Code:

if RAY then
					
					CAN_PLACE = true
					local X = math.floor(POS.X / GRID(Default is 1) + 0.5) * GRID
					local Z = math.floor(POS.Z / GRID(Default is 1) + 0.5) * GRID
					local Y = math.floor(POS.Y / GRID(Default is 1)+ 0.5) * GRID

					local NEW_CF = CFrame.new(X, Y, Z) + (SURFACE * (CURRENT_OBJECT.PrimaryPart.Size * .5))

					CURRENT_OBJECT:SetPrimaryPartCFrame(NEW_CF * CFrame.Angles(0, math.rad(CURRENT_OBJECT.PrimaryPart.Orientation.Y), 0))
					
				end
1 Like