How do I make my hinge NOT be sideways?

I’m making a hinge system and it’s sideways, for some reason.
image

How do I fix this?


local function getfurthestface(part1, part2)
	local faces = {
		Left = Vector3.new(-part2.Size.X/2, 0, 0),
		Right = Vector3.new(part2.Size.X/2, 0, 0),
		Bottom = Vector3.new(0, -part2.Size.Y/2, 0),
		Top = Vector3.new(0, part2.Size.Y/2, 0),
		Front = Vector3.new(0, 0, -part2.Size.Z/2),
		Back = Vector3.new(0, 0, part2.Size.Z/2)
	}

	local furthestface = nil
	local max = 0

	for face, offset in pairs(faces) do
		local facepos = part2.Position + offset
		local distance = (facepos - part1.Position).Magnitude
		if distance > max then
			max = distance
			furthestface = face
		end
	end

	return furthestface
end
local function posattach(part, face, opposite)
	local faceoffsets = {
		Left = Vector3.new(-part.Size.X/2, 0, 0),
		Right = Vector3.new(part.Size.X/2, 0, 0),
		Bottom = Vector3.new(0, -part.Size.Y/2, 0),
		Top = Vector3.new(0, part.Size.Y/2, 0),
		Front = Vector3.new(0, 0, -part.Size.Z/2),
		Back = Vector3.new(0, 0, part.Size.Z/2)
	}
	local oppositefaceoffsets = {
		Left = Vector3.new(part.Size.X/2, 0, 0),
		Right = Vector3.new(-part.Size.X/2, 0, 0),
		Bottom = Vector3.new(0, part.Size.Y/2, 0),
		Top = Vector3.new(0, -part.Size.Y/2, 0),
		Front = Vector3.new(0, 0, part.Size.Z/2),
		Back = Vector3.new(0, 0, -part.Size.Z/2)
	}

	local attachment = Instance.new("Attachment")
	attachment.Parent = part
	if opposite then
		attachment.Position = oppositefaceoffsets[face]
	else
		attachment.Position = faceoffsets[face]
	end
	return attachment
end
1 Like

Solved. I just didn’t rotate the hinge!
For whoever comes by this, rotate your hinge.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.