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