This code works fine there is no problem with it, my issue is that I want to assure the coordinates I receive which can only be valid in my coordinate system (using the pattern), actually fit in it for example I have a 60,4,60 baseplate and everything in the map is 4,4,4, so everything aligns perfectly. However my issue is when I'm creating this part and the player isn't aligned on the grid properly it places the part in a position where it also isn't aligned properly and this isn't allowed otherwise the idea/game won't work. Here's an example of the issue:
http://gyazo.com/59fa018157256e42ba8be77e8d10c6d7
local function Coordinates(loc)
local Pattern = ".?%d0?2?4?6?8?" --Allows negative numbers, allows any first digit but second must either be 2,4,6 or, 8 otherwise pattern will reject it.
if math.floor(loc) % 2 == 0 then
if tostring(math.floor(loc)):match(Pattern) then
return math.floor(loc)
end
elseif math.ceil(loc) % 2 == 0 then
if tostring(math.ceil(loc)):match(Pattern) then
return math.ceil(loc)
end
end
end
--Received from remote event from userinputservice local script:
local loc = Player.Character.HumanoidRootPart.Position
local X = Coordinates(loc.X)
local Y = 1.93
local Z = Coordinates(loc.Z)
--Part.Position = Vector3.new(X, Y, Z)
Is this method actually viable, or should I use something else?
