My spaceship can't turn back

So when i fly with this thing i did its impossible to go back

here is the script

local rs = game:GetService("ReplicatedStorage")
local flySpaceship = rs.FlySpaceship

local bv = Instance.new("BodyVelocity", script.Parent)
bv.MaxForce = Vector3.new(0, 0, 0)
bv.Velocity = Vector3.new(0, 0, 0)

local bg = Instance.new("BodyGyro", script.Parent)
bg.MaxTorque = Vector3.new(0, 0, 0)

flySpaceship.OnServerEvent:Connect(function(player, seat, hit)
	if script.Parent.Occupant ~= nil and script.Parent.Occupant == player.Character:FindFirstChild("Humanoid") and script.Parent == seat then
		bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
		seat.BodyGyro.CFrame = CFrame.new(seat.Parent.Body.Position, hit * 1000)
		seat:SetNetworkOwner(game.Players:GetPlayerFromCharacter(seat.Occupant.Parent))
	end
end)

script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
	if script.Parent.Occupant == nil then
		bv.MaxForce = Vector3.new(0, 0, 0)
		bg.MaxTorque = Vector3.new(0, 0, 0)
	end
end)

flySpaceship.OnServerEvent:Connect(function(player, canFly)
	if canFly == false then
		bv.MaxForce = Vector3.new(0, 0, 0)
		bg.MaxTorque = Vector3.new(0, 0, 0)
	end
end)

and i have a local script too

local rs = game:GetService("ReplicatedStorage")
local flySpaceship = rs.FlySpaceship
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local canFly = false

runService.Stepped:Connect(function()
	if player.Character ~= nil and player.Character:WaitForChild("Humanoid").Sit == true then
		seat = player.Character:WaitForChild("Humanoid").SeatPart
	end
end)

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.V and canFly == false then
		canFly = true
	elseif input.KeyCode == Enum.KeyCode.V and canFly == true then
		canFly = false
		flySpaceship:FireServer(canFly)
	end
end)

runService.Stepped:Connect(function()
	if seat and canFly == true then
		flySpaceship:FireServer(seat, mouse.Hit.Position)
		seat.BodyVelocity.Velocity = seat.CFrame.LookVector * 100
	end
end)

if you could help me i would be really thankful

2 Likes

First of all BodyGyro and BodyVelocity is deprecated use AlignPosition and AlignOrientation instead.

1 Like