Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a model move to one side?

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

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

1 comment

0

Also, to make the object go to other way, set the "-sidespeed" to "sidespeed" and "sidespeed" to "-sidespeed".

This discussion is preserved as it was. New answers, comments, and votes are closed.