im creating a tank and rn im working on the steering but the problem is that with the code i have rn the tank can only steer when W is not pressed so in order to steer you have to let go of W and i dont like that
local speed = 32
local turnSpeed = 24
local l1 = script.Parent.Parent.leftHinges.l1
local l2 = script.Parent.Parent.leftHinges.l2
local l3 = script.Parent.Parent.leftHinges.l3
local l4 = script.Parent.Parent.leftHinges.l4
local l5 = script.Parent.Parent.leftHinges.l5
local l6 = script.Parent.Parent.leftHinges.l6
local r1 = script.Parent.Parent.rightHinges.r1
local r2 = script.Parent.Parent.rightHinges.r2
local r3 = script.Parent.Parent.rightHinges.r3
local r4 = script.Parent.Parent.rightHinges.r4
local r5 = script.Parent.Parent.rightHinges.r5
local r6 = script.Parent.Parent.rightHinges.r6
local function move(rightWheels, leftWheels)
for i, hinge in script.Parent.Parent.rightHinges:GetChildren() do
for i = 1, 6 do
hinge.AngularVelocity = rightWheels
end
end
for i, hinge in script.Parent.Parent.leftHinges:GetChildren() do
for i = 1, 6 do
hinge.AngularVelocity = leftWheels
end
end
end
script.Parent.Changed:Connect(function(property)
if script.Parent.Throttle > 0 then
move(-speed, speed)
-----------------------------
elseif script.Parent.Throttle < 0 then
move(speed, -speed)
-----------------------------
elseif script.Parent.Steer < 0 then -- sterring right
move(-speed, -speed)
-----------------------------
elseif script.Parent.Steer > 0 then -- steering left
move(speed, speed)
-----------------------------
elseif script.Parent.Steer == 0 then
move(0, 0)
elseif script.Parent.throttle == 0 then
move(0, 0)
end
end)
this is the code what i want to do is make so that im able to steer my tank when im also pressing W
this is how it is so far https://gyazo.com/45a6cf48c4e117dad5043f81cda6937d