You can write your topic however you want, but you need to answer these questions:
I’m trying to make a door that opens and closes when you press one of two buttons
the issue I’m having is that the door is changing size from both sides and not just one and I need to know if its possible to make it change sides from just one side
I’ve looked on youtube and the devforum and all the solutions involve the tweenservice which i don’t want to use
local doormodel = script.Parent
local door = doormodel.doorpart
local button1 = doormodel.b1
local button2 = doormodel.b2
local goalpart1 = doormodel.goalpart1
local goalpart2 = doormodel.goalpart2
local isopen = false
local isinmotion = false
local db = 2.5
function changedoor()
if isinmotion == false then
if isopen == false then
while door.Size.Y > goalpart1.Size.Y do
wait()
door.Size -= Vector3.new(0,0.1,0)
end
isinmotion = true
isopen = true
wait(db)
isinmotion = false
elseif isopen == true then
while door.Size.Y < goalpart2.Size.Y do
wait()
door.Size += Vector3.new(0,0.1,0)
end
isinmotion = true
isopen = false
wait(db)
isinmotion = false
end
end
end
button1.ClickDetector.MouseClick:Connect(changedoor)
button2.ClickDetector.MouseClick:Connect(changedoor)
You just need to change the position of the door half as much as you are resizing it. The code should look something like this:
while door.Size.Y > goalpart1.Size.Y do
wait()
door.Size -= Vector3.new(0,0.1,0)
door.Position += Vector3.new(0,0.05,0)
end
while door.Size.Y < goalpart2.Size.Y do
wait()
door.Size += Vector3.new(0,0.1,0)
door.Position -= Vector3.new(0,0.05,0)
end
i tried doing that but the door moves up a little bit each time i open and close it
would i have to just find the right number to increase the position
Let me guess, if you select the door with the Move tool the Y axis arrows are pointing in the direction you want it to move.
Try changing @spoopmoop’s script to read
while door.Size.Y > goalpart1.Size.Y do
task.wait() -- better than using wait()
door.Size -= Vector3.new(0,0.1,0)
door.CFrame = door.CFrame * CFrame.new(0, 0.05, 0)
end
while door.Size.Y < goalpart2.Size.Y do
task.wait()
door.Size += Vector3.new(0,0.1,0)
door.CFrame = door.CFrame * CFrame.new(0, -0.05, 0)
end
This moves the door in the Y axis by 0.05 studs each time it resizes by 0.1 studs.
If it goes the wrong direction just change 0.5 to -0.5 and -0.5 to 0.5.
You could also get rid of the resize and just CFrame the door into the wall. This would mean if the door was 5 studs wide and you moved it .05 studs each time you could use a for loop to make it move.
for move = (0, 5, .05) do
door.CFrame = door.CFrame * CFrame.new(0, move, 0)
task.wait() -- this'll make it almost instant, you may want to change it to task.wait(.1) or something
end
-- you may want to put a task.wait(3) or whatever time to make the door pause when opened
for move = (5, 0, -.05) do
door.CFrame = door.CFrame * CFrame.new(0, move, 0)
task.wait()
end
And why not tweening? It’ll do the exact same thing, but more smoothly.
so Tweens are basically Roblox’s version of Microsoft Powerpoint visual effects, you would need to create 2 tweens, one for openning and the other for closing sequence, don’t forget to give your tweens proper TweenInfo and then afterwards you can just play them how you do with game sounds after you do the trigger functionality.
Edit: Now one nuance with tweens, is that you can use the same exact TweenInfo for both of em, however, you would need to have different goal. You should explore Roblox’s Engine API Reference on Documentation, you should find whatever remaining info do you need there.
If you read the tween documentation you can see that you can tween multiple Properties. @realknife you can use the same tween, just with different EasingDirections. You can even do in/out with a pause in the middle.