Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
mraznboy1 194
6 years ago
Edited 6 years ago

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.

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. wilsonsilva007 373 — 6y
0
And also how to make em move with multiple parts. SetPrimaryPartCFrame doesn't help. wilsonsilva007 373 — 6y
Ad

Answer this question