Making a part placement thing and theres this issue
I have each height being increased by 1 stud and on the odd numbered ones it has a weird offset that leaves a gap between the placement part and the part itself
this seemingly is due to this portion of my script
local SnappedObjectSpaceCF = CFrame.new(
Vector3.new(
MathUsed(objectspacecf.X),
MathUsed(objectspacecf.Y),
MathUsed(objectspacecf.Z)
)
)
which rounds it to have it be a grid-like placement system
full code
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local ClientPart = workspace.ClientMouseIgnore:WaitForChild("ClientPart")
local ClientPart2 = workspace.ClientMouseIgnore:WaitForChild("ClientPart2")
local ClientPart3 = workspace.ClientMouseIgnore:WaitForChild("ClientPart3")
local MouseRaycastParams = RaycastParams.new()
MouseRaycastParams.FilterType = Enum.RaycastFilterType.Exclude
local ClientMouseIgnoreFolder = workspace.ClientMouseIgnore
local MathUsed = math.clamp
local TweenService = game:GetService("TweenService")
local BlockTweenInfo = TweenInfo.new(0.030, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,false,0)
local function UpdatePosition(NewCF)
local BlockMoveTween = TweenService:Create(ClientPart, BlockTweenInfo, {CFrame = NewCF})
BlockMoveTween:Play()
end
local function OrientationToCFrameOrientation(Orientation : Vector3)
return CFrame.fromOrientation(math.rad(Orientation.X),math.rad(Orientation.Y),math.rad(Orientation.Z))
end
while task.wait() do
local Origin = Mouse.UnitRay.Origin
local Direction = Mouse.UnitRay.Direction
MouseRaycastParams.FilterDescendantsInstances = {ClientMouseIgnoreFolder:GetChildren(), LocalPlayer.Character}
local V1 = workspace:Raycast(Origin, Direction*1000, MouseRaycastParams)
if V1 and V1.Position and V1.Instance then
local V1Pos : Vector3 = V1.Position
local V1HitPart : Part = V1.Instance
local v1o = V1HitPart.Orientation
local objectspacecf = V1HitPart.CFrame:ToObjectSpace(CFrame.new(V1Pos + (V1.Normal * (ClientPart.Size/2))))
local SnappedObjectSpaceCF = CFrame.new(
Vector3.new(
MathUsed(objectspacecf.X),
MathUsed(objectspacecf.Y),
MathUsed(objectspacecf.Z)
)
)
local FinalCFrame = V1HitPart.CFrame * SnappedObjectSpaceCF
print(SnappedObjectSpaceCF.X, SnappedObjectSpaceCF.Y, SnappedObjectSpaceCF.Z)
print(objectspacecf.X, objectspacecf.Y, objectspacecf.Z)
UpdatePosition(FinalCFrame)
end
end