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

Can't seem to change velocity Y-value properties?

So I was trying to make a part that moves up and down endlessly in a loop

wait()
script.Parent.BodyVelocity.Velocity.Y = 2
wait(5)
script.Parent.BodyVelocity.Velocity.Y = -2
wait(5)

return

However, when I run this script, the properties of the value Y didn't change from its inital value (0,0,0). Have I done anything wrong in this case?

I'm still learning lol.

1 answer

✓ Accepted answer

I'm not experienced with Body Velocities, but here is my guess.

Velocities takes Vector3 Values, and assigning a Y Value to the Velocity won't do it.

I suggest doing this:

wait()
script.Parent.BodyVelocity.Velocity = Vector3.new(0, 2, 0)
wait(5)
script.Parent.BodyVelocity.Velocity = Vector3.new(0, -2, 0)
wait(5)
return

Though, if you're doing it in a loop, may I suggest doing a while true do loop?

while true do
	script.Parent.BodyVelocity.Velocity = Vector3.new(0, 2, 0)
	wait(5)
	script.Parent.BodyVelocity.Velocity = Vector3.new(0, -2, 0)
	wait(5)
end

Let me know if this all works out. Happy holidays!

1 comment

0

Ah, the classic Vector3, how could I have forgotten that, Many thanks!

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