I’m trying to create a cannon that you can rotate sideways by using A and D, and vertical by W and S. However, I’m not sure how I can get it to rotate vertically as my current setup is built so that my chair turns and I just welded the model to the chair. How can I make it so that I’m able to turn the cannon vertically?
local bv = script.Parent.BodyVelocity
local bav = script.Parent.BodyAngularVelocity
local seat = script.Parent
local speed = 0
local maxSpeed = 0
local rotSpeed = 0
local maxRotSpeed = 1.5
delay(0, function()
while true do
bv.velocity = seat.CFrame.lookVector * speed
bav.angularvelocity = Vector3.new(0, rotSpeed, 0)
wait()
end
end)
seat.Changed:connect(function(prop)
if prop == "Throttle" then
if seat.Throttle == 1 or seat.Throttle == -1 then
speed = maxSpeed * seat.Throttle
elseif seat.Throttle == 0 then
speed = 0
end
elseif prop == "Steer" then
if seat.Steer == -1 or seat.Steer == 1 then
rotSpeed = maxRotSpeed * -seat.Steer
elseif seat.Steer == 0 then
rotSpeed = 0
end
end
end)
Model Link: Cannnon - Creator Store