Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a model move to one side?

Asked by 9 years ago

I have this rubbish, inefficient script I made that makes a model go UP. How would I make a more efficient type, that moves 5 studs in 5 seconds?

01function DoorOpen()
02    script.Parent.Parent.DoTTAlarm.Button1.ClickDetector.MaxActivationDistance = 0
03    wait(.1)
04    script.Parent.Parent.DoTTAlarm.Button1.BrickColor = BrickColor.new(21)
05    wait(2)
06    script.Parent.Parent.DoTTAlarm.Alarm.Sound:Play()
07    wait(5)
08    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
09    wait(1)
10    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
11    wait(1)
12    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
13    wait(1)
14    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
15    wait(1)
View all 94 lines...

1 answer

Log in to vote
0
Answered by 9 years ago

Well, just for a start, you could use one single one with a movement & speed vector. Let me show you an example:

To go to the side: To open:

1--Your function etc--
2sidemoves=250
3sidespeed=0.1
4for i=1,sidemoves do
5wait(0.01)
6script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(sidespeed,0,0)
7end

To close:

1--Your function etc--
2sidemoves=250
3sidespeed=0.1
4for i=1,sidemoves do
5wait(0.01)
6script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(-sidespeed,0,0)
7end

To go up: Open:

1movements=37
2speed=0.2
3for i=1,movements do
4wait(0.01)
5script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(0,speed,0);
6end

Close:

1movements=37
2speed=0.2
3for i=1,movements do
4wait(0.01)
5script.Parent.PLT.CFrame = script.Parent.PLT.CFrame + Vector3.new(0,-speed,0);
6end
0
Also, to make the object go to other way, set the "-sidespeed" to "sidespeed" and "sidespeed" to "-sidespeed". TheHospitalDev 1134 — 9y
Ad

Answer this question