Door puzzle script failure or bug

Why is the door still not closing even though i changed the middle orientation
robloxapp-20200822-1719412.wmv (614.8 KB)

local p1 = game.Workspace.PuzzlePart1
local p2 = game.Workspace.PuzzlePart2
local p3 = game.Workspace.PuzzlePart3
local door = game.Workspace["Puzzle Door"]

while wait() do
	if p1.Orientation and p2.Orientation and p3.Orientation == Vector3.new(0,0,0) then
		door.CanCollide = false
		door.Transparency = 0.5
	else
		door.CanCollide = true
		door.Transparency = 0
	end
end

Did you send the wrong video because I only see Lumber Tycoon 2 clip in that video.

The video wasn’t clear to me.
However, you’re checking only if the last orientation is equal to Vector3.new(0,0,0)
I am pretty sure you can’t do something like this:

local nums = {1,1,1}

if nums[1] and nums[2] and nums[3] == 0 then

end

oh ok how can i change it to all orientation?

i fixed the video donwload it again

i fixed it now
thank youu for noticing

1 Like

is there such a thing as get all children().Orientation = Vector3.new()

why is this not working

local puzzleparts = game.Workspace.PuzzleParts

local door = game.Workspace["Puzzle Door"]

while wait() do
	if puzzleparts:GetChildren().Orientation == Vector3.new(0,0,0) then
		door.CanCollide = false
		door.Transparency = 0.5
	else
		door.CanCollide = true
		door.Transparency = 0
	end
end

You can put it in a for loop and change their orientations like this:

for i,v in pairs(Instance:GetChildren()) do --Change "Instance" with the object you're trying to get it's children off.
v.Orientation = Vector3.new()
end
1 Like

but i need an if statement so that when all of the children’s orientation is = to 0,0,0 the door will open

No, you’ll have to loop though get children.
You can make a Boolean, loop through the puzzles, and if they are all correct, it’s true.

can you give me a code example

local puzzleparts = game.Workspace.PuzzleParts

local door = game.Workspace["Puzzle Door"]

for i,v in pairs(puzzleparts:GetChildren()) do
	if v.Orientation == Vector3.new(0,0,0) then
		door.CanCollide = false
		door.Transparency = 0.5
	else
		door.CanCollide = true
		door.Transparency = 0
	end
end

i tried this but its not working

Yes.
Example:

local val = false

for I,v in pairs(puzzles:GetChildren()) do --loop through them
if(v.Orientation== Vector3.new(0,0,0) then -- check orientation
val = true
else
val = false
break 
end
end)

and later check if it’s true, if it is, do whatever you want to the door.

local puzzleparts = game.Workspace.PuzzleParts

local door = game.Workspace["Puzzle Door"]

for i,v in pairs(puzzleparts:GetChildren()) do
	if v.Orientation == Vector3.new(0,0,0) then
		door.CanCollide = false
		door.Transparency = 0.5
	else
		door.CanCollide = true
		door.Transparency = 0
	end
end

this doesn’t work

This won’t work, you need to check if they are all correct, I gave you an example.

The value is true when they are all correct.

but i used your example though

You didn’t use his example at all in the latest code you gave us.

1 Like

That’s not mine, I didn’t change it every time I looped through. I checked when I looped through, and when I did and the value is true, I changed the door.

That’s mine:

It’s hard for me to space right here because my Tab button isn’t working, sorry if it’s a little hard to read.

1 Like

From what I see, your loop is supposed to check the three orientations regularly for them to match.

Can you not just do (or am I wrong?):

if p1.Orientation == Vector3.new(0,0,0) and p2.Orientation == Vector3.new(0,0,0) and p3.Orientation == Vector3.new(0,0,0) then

--code here

end