How would I rotate a look vector by 90 and 180 degrees

I’m making a plane template PBS stamper block and was wondering how I would make get the left of a look vector rear and right.

sp=script.Parent
bv=script.Parent.BodyVelocity
io=script.Parent.IsOn

bv.velocity = Vector3.new()
bv.maxForce = Vector3.new(1e6,1e6,1e7)
local vecset = Vector3.new()
sp.ForwardThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		vecset = sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.LeftThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		vecset = sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.RightThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		vecset = sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)

sp.RearThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		vecset =  sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value:inverse()
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)


game["Run Service"].Stepped:Connect(function(step)
	if io.Value == true then
		bv.Velocity = vecset
	end
end)

There is a cframe.RightVector which will get what you want. For the other two directions just get negative LookVector and negative RightVector.

CFrame.LookVector
CFrame.RightVector
-CFrame.LookVector
-CFrame.RightVector
1 Like
sp=script.Parent
bv=script.Parent.BodyVelocity
io=script.Parent.IsOn
local valt
bv.velocity = Vector3.new()
bv.maxForce = Vector3.new(1e6,1e6,1e7)
local vecset = Vector3.new()
sp.ForwardThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 1
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.LeftThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 2
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.RightThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 3
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)

sp.RearThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 4
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)


game["Run Service"].Stepped:Connect(function(step)
	if io.Value == true then
		if valt == 1 then
			bv.MaxForce = sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value

		elseif valt == 2 then
			bv.MaxForce =  -sp.CFrame.RightVector * sp.Parent.Configuration.Speed.Value
		elseif valt == 3 then
			bv.MaxForce =  sp.CFrame.RightVector * sp.Parent.Configuration.Speed.Value
		elseif valt == 4 then
			bv.MaxForce = -sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value
		else
			
		end
	end
end)

Still doesnt function

and im setting maxforce not velocity

update

sp=script.Parent
bv=script.Parent.BodyVelocity
io=script.Parent.IsOn
local valt
bv.velocity = Vector3.new()
local vecset = Vector3.new()
sp.ForwardThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 1
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.LeftThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 2
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)
sp.RightThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 3
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)

sp.RearThrust.SourceValueChanged:connect(function(val)
	if val==1 then
		io.Value = true
		valt = 4
	elseif val==0 then
		bv.MaxForce = Vector3.new()
		bv.Velocity = Vector3.new()
		io.Value = false
	end
end)


game["Run Service"].Stepped:Connect(function(step)
	if io.Value == true then
		bv.maxForce = Vector3.new(1e6,1e6,1e7)
		if valt == 1 then
			print(valt)

			bv.Velocity = sp.CFrame.LookVector * sp.Parent.Configuration.Speed.Value

		elseif valt == 2 then
			print(valt)
			bv.Velocity =  (-sp.CFrame.RightVector) * sp.Parent.Configuration.Speed.Value
		elseif valt == 3 then
			print(valt)

			bv.Velocity =  sp.CFrame.RightVector * sp.Parent.Configuration.Speed.Value
		elseif valt == 4 then
			print(valt)

			bv.Velocity = (-sp.CFrame.LookVector) * sp.Parent.Configuration.Speed.Value
		else
			
		end
	end
end)

valt doesnt change from 1
@tlr22

You have a lot of repeating code. Try making one function, with an input. Your code will look a lot better! And about the topic. You can use “CFrame.LookVector”, “CFrame.RightVector” and “CFrame.UpVector” as @FusionOak mentioned. You can add a “-” before the vector to invert it’s direction (-CFrame.RightVector = left). Should work