Hello there! I wanna make this part
place on floor. Lemme tell you
I have this:
local params = RaycastParams.new()
params.FilterDescendantsInstances = {workspace.Map, workspace.Breakable_Parts}
params.FilterType = Enum.RaycastFilterType.Include
local params2 = OverlapParams.new()
params2.FilterDescendantsInstances = {workspace.Map, workspace.Breakable_Parts}
params2.FilterType = Enum.RaycastFilterType.Include
local downRay = workspace:Raycast(HRP.Position, -HRP.CFrame.UpVector*10000, params)
local part = downRay~=nil and downRay.Instance
local inBox = workspace:GetPartBoundsInBox(box.CFrame, box.Size, params2)
local max_pos_y = -math.huge
local max_size_y = -math.huge
for _,hit:Part in pairs(inBox) do
if hit.Position.Y>max_pos_y then
max_pos_y = hit.Position.Y
max_size_y = hit.Size.Y
end
end
box.CFrame = (CFrame.new(HRP.Position.X,max_pos_y,HRP.Position.Z)*CFrame.Angles(HRP.CFrame:ToOrientation()))*CFrame.new(0,0,-module.wall_offset_z)*CFrame.new(0,(max_size_y+box.Size.Y)/2,0)
if (box.Position-HRP.Position).Magnitude-(HRP.Position.Y+box.Position.Y)/2>40 then
box.CFrame = (CFrame.new(HRP.Position.X,part.Position.Y,HRP.Position.Z)*CFrame.Angles(HRP.CFrame:ToOrientation()))*CFrame.new(0,0,-module.wall_offset_z)*CFrame.new(0,(part.Size.Y+box.Size.Y)/2,0)
end
this all in the RenderStepped cycle
And I have a problem. How do I can correctly place the part on the top of the some part? Cuz when I have 2 parts on each other and the box position sets, so then the box starts glitching, like teleporting on the floor (Baseplate) and first part (Ice part)