Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a door move via CFrame without unioning it?

I don't know how to do CFrame for a door with a lot of parts, but unioning it is the only way I can get it working. How do I do that?

local cf = script.Parent.CFrame
function onClicked()
	if script.IsOpened.Value == false and script.IsOpening.Value == false then
		script.IsOpening.Value = true
		for i = 1,16 do
			script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.18) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
			wait(0.01)
		end
		script.IsOpening.Value = false
		script.IsOpened.Value = true
	elseif script.IsOpened.Value == true and script.IsOpening.Value == false then
		script.IsOpening.Value = true
		for i = 1,16 do
			script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
			wait(0.01)
		end
		script.IsOpening.Value = false
		script.IsOpened.Value = false
		script.Parent.CFrame = cf
		script.CloseSound:Play()
	end
end
--script.Parent.ClickDetector.MouseClick:connect(onClicked)
script.Parent.Touched:connect(onClicked)


while true do
	wait(15)
	if script.IsOpened.Value == true then
		script.IsOpening.Value = true
		for i = 1,16 do
			script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
			wait(0.01)
		end
		script.IsOpening.Value = false
		script.IsOpened.Value = false
		script.Parent.CFrame = cf
	end
end

2 comments

0

Try welding the parts in the model to a part to act as a hinge. It would be much easier.

0

I'll try it out

1 answer

Group the parts of the door together, set a primary part of the model, and use

Model:SetPrimaryPartCFrame(CFrame)

to move the whole model together.

1 comment

0

I’ll try it out. Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.