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

Stop Delay for Moving Parts?

I've made a script where a part or model will move to an exact spot, then move to another one at a constant speed. This works fine in studio, but in-game the model changes path prematurely or too late.

Move = script.Parent
Movevelocity = Move.BodyVelocity

while true do
wait(1)
Movevelocity.velocity = Vector3.new(0,0,14)
wait(4.3)
Movevelocity.velocity = Vector3.new(-14,0,0)
wait(12.1)
Movevelocity.velocity = Vector3.new(0,0,14)
wait(9.15)
Movevelocity.velocity = Vector3.new(-14,0,0)
wait(10)
end

I'm using a BodyVelocity with the script. Lag or memory usage doesn't seem to be the problem. Can anyone help me figure out what's going wrong?

Thanks.

2 comments

0

Well you could just change the whole part with Move.Position = Vector3.new(urpos)

0

The problem with this is that I want the model moving at a constant speed. Such as a car going through a city. BodyPosition will just teleport the model instead.

2 answers

You have wait() delays in your code. Shorten them and see if it's faster now.

4 comments

0

Those are there for the model to wait a certain amount of time to change direction. What I mean in my question is that the model is supposed to stop at a certain point. And in-game the model will usually go past that point.

0

Use If Statements to make sure the part is not pasted it's point.

0

That makes perfect sense to me, but I can't seem to implement them without the script breaking.

0

Shorten the Vector3 values.

To achieve what you're trying to do, you can instead use TweenService. It will be much smoother and less delayed. The only thing you have to worry about is to make sure the BasePart is Anchored

local TweenService = game:GetService("TweenService")
local Move = script.Parent
-- Movevelocity = Move.BodyVelocity (Remove the body velocity)

while true do
	wait(1)
	TweenService:Create(Move, TweenInfo.new(1), {Position = Vector3.new(0,0,14)}):Play()
	wait(1)
	TweenService:Create(Move, TweenInfo.new(4.3), {Position = Vector3.new(-14,0,0)}):Play()
	wait(4.3)
	TweenService:Create(Move, TweenInfo.new(12.1), {Position = Vector3.new(-14,0,0)}):Play()
	wait(12.1)
	TweenService:Create(Move, TweenInfo.new(9.15), {Position = Vector3.new(0,0,14)}):Play()
	wait(9.15)
	TweenService:Create(Move, TweenInfo.new(10), {Position = Vector3.new(0,0,14)}):Play()
	wait(10)
end

Just make sure to edit the position and timing and you should get the results you want.

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