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!!
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.