Hello there,
I am working on a system that enables the player to drag a part around.
Everything works fine, except the fact that the part is sticking halfway in the floor or wall or whatever.
I already have a solution to this problem but… it’s not effective and doesn’t work at corners.
And the solution doesn’t make me feel yummi, yk?
local function POS_UPADTE()
if mouse.Target then
part.CFrame = mouse.Hit
if part.Touched then
if mouse.TargetSurface.Name == "Top" then
part.CFrame = part.CFrame + Vector3.new(0,part.Size.Y/2,0)
elseif mouse.TargetSurface.Name == "Front" then
part.CFrame = part.CFrame + Vector3.new(0,0,-part.Size.Z/2)
elseif mouse.TargetSurface.Name == "Right" then
part.CFrame = part.CFrame + Vector3.new(part.Size.X/2,0,0)
elseif mouse.TargetSurface.Name == "Bottom" then
part.CFrame = part.CFrame + Vector3.new(0,-part.Size.Y/2,0)
elseif mouse.TargetSurface.Name == "Back" then
part.CFrame = part.CFrame + Vector3.new(0,0,part.Size.Z/2)
elseif mouse.TargetSurface.Name == "Left" then
part.CFrame = part.CFrame + Vector3.new(-part.Size.X/2,0,0)
end
end
end
end
so I need help or hints to handle this problem, in the end, you shouldn’t be able to push it inside other parts anymore … some ideas?