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

Door not stopping, why is this happening?

Asked by 3 years ago
Edited 3 years ago

Hi. I am making a game and have tried to make a door but it will not stop opening. It just flies off into the distance. Here is my code:

local doorOpen = false
local Keycards = {
    'Staff Card'
}

script.Parent.Touched:Connect(function(hit)
    for i, v in pairs(Keycards) do
        if hit.Parent.Name == v then
            if doorOpen == false then
                while script.Parent.Parent.Door.Position ~= Vector3.new(2.75, 3.6, -7.5) do
                    script.Parent.Parent.Door.CFrame = CFrame.new(script.Parent.Parent.Door.Position - Vector3.new(0, 0, 0.1))
                    wait(0.01)
                end
            elseif doorOpen == true then
                while script.Parent.Parent.Door.Position ~= Vector3.new(2.75, 3.6, -3) do
                    script.Parent.Parent.Door.CFrame = CFrame.new(script.Parent.Parent.Door.Position + Vector3.new(0, 0, 0.1))
                    wait(0.01)
                end
            end
        end
    end
end)
0
have you tried changing the orientation instead of the position of the door? WorriedClocks 0 — 3y
0
I didnt say i was trying to rotate it PufferfishDev 49 — 3y
0
well you didnt specify anything you kind of just said you made a door and it had an error and didnt really relate anything to the text WorriedClocks 0 — 3y
0
No I didn't. PufferfishDev 49 — 3y
View all comments (2 more)
0
Wow man I cant believe you stole someones ip address WorriedClocks 0 — 3y
0
what do you mean he stole someone iMazariuz 36 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Nobody seems to understand simple english, so I am closing this question.

0
Dude why are you making it so hard on yourself. Just tween the door. iMazariuz 36 — 2y
Ad
Log in to vote
0
Answered by 3 years ago

So i believe you were trying to make a sliding door. If so then. I don't know exactly where your problem is, but think it's somewhere along the lines of using a 'while'.

I've made one myself and it's working. Without 'while' or anything. Just set the CFrame into yourDoor.CFrame + Vector3.new(wherever you want it to slide). Well I actually wanted to provide you my code but since you said you're closing this question then I'm gonna end it here.

Answer this question