CFrame not working

Hey Developers,
I’m making an animated ticket gate, I’m getting an extremely strange error:

I’ve clicked on the error and it takes me to my script. I press Control + F and search Door1, but there is no results. Here is my script

local debounce = false
local inc,cyc,dir = math.rad(5),18,0


function OpenGate()
debounce = true
for _=1,cyc do
for i=1,3 do
script.Parent.D1.Parts["Door"..i].CFrame = script.Parent.D1.Parts["Door"..i].CFrame*CFrame.fromEulerAnglesXYZ(0,0,inc*dir)
end
for i=1,3 do
script.Parent.D2.Parts["Door"..i].CFrame = script.Parent.D2.Parts["Door"..i].CFrame*CFrame.fromEulerAnglesXYZ(0,0,-inc*dir)
end wait(.05) end
wait(0.75)
for _=1,cyc do
for i=1,3 do
script.Parent.D1.Parts["Door"..i].CFrame = script.Parent.D1.Parts["Door"..i].CFrame*CFrame.fromEulerAnglesXYZ(0,0,-inc*dir)
end
for i=1,3 do
script.Parent.D2.Parts["Door"..i].CFrame = script.Parent.D2.Parts["Door"..i].CFrame*CFrame.fromEulerAnglesXYZ(0,0,inc*dir)
end wait(.05) end
debounce = false
dir = 0
end

This is the explorer layout:
ddsaadfsafdsadfsds

Thanks for any help! :slight_smile:

Can u show the explorer and the place where Door1 is located?

ddsaadfsafdsadfsds

I dont see Door1 anywhere… u got only Door

Uhm, I don’t mention door1 anywhere, that’s the error. It’s saying door1 doesn’t exist but I don’t refrence door1 anywhere.

You’re saying [“Door”…i], but none of your parts inside of the model have just Door and number. You reference Door1 when you say [Door…i]

So I need to rename the door to door1?

No, i in for loops are representing the number of the loop playing in ur example 1, 2, 3

Which part inside of the parts model are you trying to move?

script.Parent.D1.Parts.Door.CFrame = script.Parent.D1.Parts.Door.CFrame*CFrame.fromEulerAnglesXYZ(0,0,inc*dir)
end
1 Like

It’s always going to error if the dependency your searching for doesn’t exist. Also if this helps using Motor6D rather than CFrame in my opinion may help as I have made gates similar to this. But CFrame works fine.

To do this with Motor6D You weld one part of the door in parts to single part than make sure they are unanchored. After this add a motor 6d and motor that main door part which holds all the welds. Following this you could do

So if you were to make D1 the point from which the door swivels from it would look like this

im just using x as some imaginary number

script.Parent.TicketScanner.D1.Motor.DesiredAngle = x.

Good Luck! C:

To put it simply.

The code you have inputted does the following:

As a counter goes up in the for loop, as does the value “i”, however “i” begins at 1, therefore when

for i=1,3 do

is run, you are saying:

Starting from one, I want you to find Door1 and Cframe it, then I want you to repeat and find Door2, then Door3, then move on to the next part of the code.

From what I see in your code, just remove the …i and you should be good, so in conclusion,

script.Parent.D1.Parts.Door.CFrame = script.Parent.D1.Parts.Door.CFrame*CFrame.fromEulerAnglesXYZ(0,0,inc*dir)

Note: If there is an issue with cframes I did not solve it.