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

How do I make a door?(Sliding Door)(Not tweeninfo) This door keeps on giving errors on the output.

Guys I have a problem.

local doubledoor = script.Parent.Parent
local door1 = doubledoor.Doors.Door1.Mainframe
local door2 = doubledoor.Doors.Door2.Mainframe
local click = script.Parent.ClickDetector
local IsOpen = false

function OpenDoor()
	for i = 1,45 do
				door1.CFrame = door1.CFframe * CFrame.new(0,0,0.08) * CFrame.fromEulerAnglesXYZ(0,0,0)
				wait()
			end
		end
script.Parent.ClickDetector.MouseClick:connect(function()
	OpenDoor()
end)

The script is supposed to make a door open. But everytime I click the button to open it the output says:

Stack Begin 16:40:03.619 - Script 'Workspace.DoubleDoor.Button.Script', Line 9 - global OpenDoor 16:40:03.620 - Script 'Workspace.DoubleDoor.Button.Script', Line 14 16:40:03.621 - Stack End WHY IS THIS HAPPENING!!

1 answer

✓ Accepted answer

Hey, theres a few problems with your code. Starting with the OpenDoor function, you have a small typo here:

 door1.CFrame = door1.CFframe * CFrame.new(0,0,0.08) * CFrame.fromEulerAnglesXYZ(0,0,0)

where you had an extra 'f' in door1.CFrame. Next, you called the event from within the function itself, so the event never connects when the script starts. To fix this, move the event to outside of the function.


function OpenDoor()
	--openn door code
end

script.Parent.ClickDetector.MouseClick:connect(OpenDoor)

You should end up with something similar to this:

local doubledoor = script.Parent.Parent
local door1 = doubledoor.Doors.Door1.Mainframe
local door2 = doubledoor.Doors.Door2.Mainframe
local click = script.Parent.ClickDetector
local IsOpen = false

function OpenDoor()
    for i = 1,45 do
        door1.CFrame = door1.CFrame * CFrame.new(0,0,0.08) * CFrame.fromEulerAnglesXYZ(0,0,0)
        wait()
	end
end

script.Parent.ClickDetector.MouseClick:connect(OpenDoor)

edit: whoops, just saw your code and realized you didn't connect the event from in the function, my mistake. The above code should still work though.

2 comments

0

I used Remove Events to make the 2 doors move at the same time. But, do you know how to make them move FASTER? I'm afraid if I remove the wait I will crash.

0

And also how to make em move with multiple parts. SetPrimaryPartCFrame doesn't help.

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