local B = script.Parent.Parent.B
script.Parent.Touched:Connect(function()
while true do
wait(0.0000001)
if B.B.CFrame.Y > -3.971 then
B.B.CFrame = B.B.CFrame * CFrame.new(0, -0.1, 0)
elseif B.B.CFrame.Z < -80.145 then
B.B.CFrame.Z = B.B.CFrame.Z * CFrame.new(0, 0, 0.1)
end
end
wait(4)
while true do
wait(0.0000001)
if B.B.CFrame.Y < 3.029 then
B.B.CFrame = B.B.CFrame * CFrame.new(0, 0.1, 0)
elseif B.B.CFrame.Z > -82.145 then
B.B.CFrame = B.B.CFrame * CFrame.new(0, 0, -0.1)
else
break
end
end
end)
For some reason, the following code changes the X value of a union’s position instead of the Z value, as it is supposed to. It also doesn’t change the Y value of the part, as it is supposed to. robloxapp-20211222-1954151.wmv (1.1 MB)
I honestly have no idea why it is doing this. The CFrame stuff is working with all the other parts of the sliding door. No errors are showing up in output. I’ve tried changing some of the values and messing with the comparison signs, but nothing has worked.
Select “B” with the Move tool.
Make sure you don’t have the Global tool selected (if so then CTRL L will toggle it to Local).
See which way the Y axis of B is pointing and those are the directions your script is affecting on part B.
Why are you checking for 2 directions (Y and Z) in your script?
Also you don’t need to try to force a wait() down to .0000001 seconds. I believe that the frame rate in ideal conditions is 1/30th of a second, so you can’t force wait() to be less than .0333 seconds.
For a simple door movement script I’d just do
local B = script.Parent.Parent.B
local debounce = false
script.Parent.Touched:Connect(function()
if debounce = false then
for loop = 1, 30 do --(whatever values work for your case)
wait()
B.B.CFrame = B.B.CFrame * CFrame.new(0, -0.1, 0)
B.B.CFrame.Z = B.B.CFrame.Z * CFrame.new(0, 0, 0.1)
end
wait(4)
for loop = 1, 30 do --(whatever values work for your case)
wait()
B.B.CFrame = B.B.CFrame * CFrame.new(0, 0.1, 0)
B.B.CFrame = B.B.CFrame * CFrame.new(0, 0, -0.1)
end
wait(2) --(how long you want for the door to be able to be opened again)
debounce = true
end)
I’m checking it because I want it to move 0.1 at a time, so thus it’s a sliding loop, and when it gets in the correct Y position, it moves over to the Z, and then when it is done with both, it breaks the loop.
There is a break in the loops. And yes, both loops are running. The code after the first loop does work. I will look at that video however, and also take a look at the rotations of the part, although I already have checked the rotations previously. Perhaps I may have missed something.