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)
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)
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