I have the following line in one script, I’m trying to make a simple space shuttle design that can move around in any direction. Is there a way to better alter just one variable (X/Y/Z) without having to alter the other two? If not I guess I can just make numberValues with the existing variables and put them in the place of the other two as the script alters the third.
game.Workspace.Mover.BodyVelocity.Velocity = Vector3.new(0,existingY+1,0)
To simplify above, is it possible to do modify the past line to something like the following, but accurately formatted (since this doesn’t work):
game.Workspace.Mover.BodyVelocity.Velocity = Vector3.Y.new(existingY+1)
BanTech
(BanTech)
July 17, 2020, 10:48pm
2
To add a value, let’s call it addY,
local curVelocity = game.Workspace.Mover.BodyVelocity.Velocity
local newVelocity = curVelocity + Vector3.new( 0, addY, 0 )
game.Workspace.Mover.BodyVelocity.Velocity = newVelocity
To clear the existing Y value and overwrite it with newY,
local newVelocity = curVelocity * Vector3.new( 1, 0, 1 ) + Vector3.new( 0, newY, 0 )
-- or
local newVelocity = Vector3.new( curVelocity.X, newY, curVelocity.Z )
Alright, perfect. I wasn’t sure if there was the option to literally just manage a single one of the values (X/Y/Z). I appreciate the help.
Sorry im bringing this back, but I ran into this same issue, this is the code in my case.
while true do
script.Parent.BodyVelocity.Velocity = script.Parent.Parent.Speed.Value
wait(0.1)
end
The Value is just a single digit number, for the x value.
do
while true do
script.Parent.BodyVelocity.Velocity += Vector3.new(script.Parent.Parent.Speed.Value, 0, 0)
wait(0.1)
end
1 Like
This actually allows for a really cool drive system, thank you, this is fun to play with.