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 8 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?

function DoorOpen() 
    script.Parent.Parent.DoTTAlarm.Button1.ClickDetector.MaxActivationDistance = 0
    wait(.1)
    script.Parent.Parent.DoTTAlarm.Button1.BrickColor = BrickColor.new(21)
    wait(2)
    script.Parent.Parent.DoTTAlarm.Alarm.Sound:Play()
    wait(5)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,0.5,0))
    wait(30) --CHECKPOINT
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(1)
    script.Parent:TranslateBy(Vector3.new(0,-0.5,0))
    wait(3)
    script.Parent.Parent.DoTTAlarm.Button1.BrickColor = BrickColor.new(28)
    wait(1)
    script.Parent.Parent.DoTTAlarm.Button1.ClickDetector.MaxActivationDistance = 10
    wait(1)
    script.Parent.Parent.DoTTAlarm.Alarm.Sound:Stop()
end

script.Parent.Parent.DoTTAlarm.Button1.ClickDetector.MouseClick:connect(DoorOpen)


1 answer

Log in to vote
0
Answered by 8 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:

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

To close:

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

To go up: Open:

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

Close:

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

Answer this question