Ok, so you had a few errors here. I'll take you through them step by step, and give you the finished script at the end.
for i = 1, 10 do
dtop.Position.Vector3 = CFrame.new() + Vector3.new(0,1,0)
dbottom.Position.Vector3 = CFrame.new() + Vector3.new(0,1,0)
break
end
(This chunk is basically where all your errors took place)
First of all, you did:
dtop.Position.Vector3
dbottom.Position.Vector3
This is incorrect because there is no Property for Vector3. Vector3 is a DataType that is used to set physical traits of an object such as Position, Size, Velocity ect. To use Vector3 correctly, you need to do something like this:
dtop.Position = Vector3.new(1,5,1)
Secondly, you tried to add the CFrame Position, and Vector3 Position of the objects together.
CFrame.new() + Vector3.new(0,1,0)
You also cannot do this. This results in errors, because DataTypes can only be used with their own DataType. Also, you left the arguments in the first part empty. That sets the initial position. To fix this, we'll change the entire script to using CFrame instead of using CFrame and Vector3, and then we'll fill in those values:
dtop.CFrame = CFrame.new(dtop.Position) * CFrame.new(0,1,0)
dbottom.CFrame = CFrame.new(dbottom.Position) * CFrame.new(0,1,0)
lastly, you had a break in the loop.
break
When you use a break, it ends the current loop that's running. Breaks don't normally need to be used unless you have a function that can run indefinitely which can become an infinite loop. When you used it in your function, it ended the current loop that was running, so that it only moved the blocks up once before it was removed.
Now for the finished script!
base = script.Parent.Parent.Parent
dtop = base.SecurityDoor.TopDoor
dbottom = base.SecurityDoor.BottomDoor
function onClicked()
for i = 1, 10 do
wait()
dtop.CFrame = CFrame.new(dtop.Position) * CFrame.new(0,1,0)
dbottom.CFrame = CFrame.new(dbottom.Position) * CFrame.new(0,1,0)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
So, I cleaned up your script a bit, and I believe I fixed pretty much everything that was wrong with it. I understand this can be alot to try to learn all at once, so if you have any further problems/questions, please leave a comment below. Hope I helped :P
4 comments
Your finished version of the script still uses the wrong
CFrame.new(). Also: CFrame + Vector3 is totally fine; and CFrame * CFrame.new(Vector3) is slightly different -- the multiplication will take it in the direction of its Top face, while the + will actually take it UP.Change wait(.1) to wait() since wait() is around 0.03 seconds which is the same speed animations and movies change frames.
Oh and btw BlueTaslm is right, for Example: CFrame.new(Vector3.new(0,10,0)) would work.
I knew that Lord, but I didn't know you could do CFrame + Vector3