Im currently working on a tank game and i can move the turret right and left but not up and down, can anybody help?
The movement code currently
if Turret.TurretSeat.Steer == 1 then
Turret:PivotTo(Turret:GetPivot() * CFrame.Angles(0, -math.rad(1), 0))
elseif Turret.TurretSeat.Steer == -1 then
Turret:PivotTo(Turret:GetPivot() * CFrame.Angles(0, math.rad(1), 0))
end
if Turret.TurretSeat.Throttle == 1 then
-- idk what to put here
elseif Turret.TurretSeat.Throttle == -1 then
-- idk what to put here
end
The whole script currently, the Barrel is what i want to move
local RunService = game:GetService("RunService")
local Turret = script.Parent.Turret
local Hull = script.Parent.Hull
local Gun = Turret.Gun.Barrel
coroutine.resume(coroutine.create(function()
RunService.Heartbeat:Connect(function()
if Turret:FindFirstChild("TurretSeat") then
if Turret.TurretSeat.Steer == 1 then
Turret:PivotTo(Turret:GetPivot() * CFrame.Angles(0, -math.rad(1), 0))
elseif Turret.TurretSeat.Steer == -1 then
Turret:PivotTo(Turret:GetPivot() * CFrame.Angles(0, math.rad(1), 0))
end
if Turret.TurretSeat.Throttle == 1 then
Gun:PivotTo(Gun:GetPivot() * CFrame.Angles(-math.rad(1), 0, 0))
elseif Turret.TurretSeat.Throttle == -1 then
Gun:PivotTo(Gun:GetPivot() * CFrame.Angles(math.rad(1), 0, 0))
end
end
end)
end))