So I'm trying to make a door and to make it rotate around a certain hinge. But I can't do it. I mean it works but it doesn't move around the hinge. Any ideas? Code

local TweenService = game:GetService("TweenService")
local Model = script.Parent.Parent
local OpenPos = Model.OpenPos
local ClosePos = Model.ClosePos
local Door = Model.Door
local DoorName = Model.DoorName.Value
local TriggerBrick = script.Parent
local IsMoving = false
local ForceOpen = false
local ForceClose = false
local Delete = TriggerBrick:GetChildren()
script.Parent.Parent.PrimaryPart = script.Parent.Parent.OpenPos

for i,v in pairs(Delete) do
	if v:IsA("Texture") then
		v:Destroy()
	end
end
local TweenSetting = TweenInfo.new(

	5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	false,
	0
)
local ClosePosCF = {CFrame = CFrame.new(ClosePos.CFrame.Position) * CFrame.Angles(math.rad(ClosePos.Orientation.X), math.rad(ClosePos.Orientation.Y), math.rad(ClosePos.Orientation.Z))}
local OpenPosCF = {CFrame = CFrame.new(OpenPos.CFrame.Position) * CFrame.Angles(math.rad(OpenPos.Orientation.X), math.rad(OpenPos.Orientation.Y), math.rad(OpenPos.Orientation.Z))}
local TweenOpenPos = TweenService:Create(Door, TweenSetting, OpenPosCF)
local TweenClosePos = TweenService:Create(Door, TweenSetting, ClosePosCF)
function openDoor()
	if ForceClose ~= true then
		IsMoving = true
	
	TweenOpenPos:Play()
	wait(6)
	if ForceOpen ~= true then
	TweenClosePos:Play()
	wait(0.1)
	IsMoving = false
	else
	IsMoving = false	
	end
	
end
	end
		 
	
TriggerBrick.Touched:Connect(function(part)
	local hum = part.Parent:FindFirstChild("Humanoid")
	
	if hum then
		
			openDoor()
			
		
	end
end)

function closeDoor()
	IsMoving = true
	if not ForceOpen then
		TweenClosePos:Play()
	end
end

2 comments

0

is your primary part the hinge or the door?

0

@sitferr There was no primary part before but as mentioned on line 12 I set the hinge to the open pos.