In my opinion, BodyMovers are confusing. I'm trying to make a script that flips a car upright whenever you press V. However, it's not doing that, and making the car turn erratically instead. I'm using a BodyGyro to flip the car by the way. Here is my script:
local player = game.Players.LocalPlayer local camera = workspace.CurrentCamera local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local UserInputService = game:GetService("UserInputService") local inCar = false local vehicle local function onSit(Sitting, seat) if Sitting == true then if seat.Name == "DriveSeat" then inCar = true vehicle = seat.Parent.Parent camera.FieldOfView = 100 repeat wait() camera.CameraType = Enum.CameraType.Attach until camera.CameraType == Enum.CameraType.Attach end else inCar = false camera.FieldOfView = 70 repeat wait() camera.CameraType = Enum.CameraType.Custom until camera.CameraType == Enum.CameraType.Custom end end local function flipCar(car) if inCar then local yRot = car:FindFirstChild("Car Weld").DriveSeat.Orientation.Y local seat = car:FindFirstChild("Car Weld").DriveSeat seat:FindFirstChild("BodyGyro").CFrame = CFrame.fromOrientation(0, -1*yRot, 0) end end local function flip(Input) if Input.KeyCode == Enum.KeyCode.V then flipCar(vehicle) end end humanoid.Seated:Connect(onSit) UserInputService.InputBegan:Connect(flip)
Any help would be appreciated.
Hope this helps!
local player = game.Players.LocalPlayer local camera = workspace.CurrentCamera local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local UserInputService = game:GetService("UserInputService") local inCar = false local vehicle local function onSit(Sitting, seat) if Sitting == true then if seat.Name == "DriveSeat" then inCar = true vehicle = seat.Parent.Parent camera.FieldOfView = 100 repeat wait() camera.CameraType = Enum.CameraType.Attach until camera.CameraType == Enum.CameraType.Attach end else inCar = false camera.FieldOfView = 70 repeat wait() camera.CameraType = Enum.CameraType.Custom until camera.CameraType == Enum.CameraType.Custom end end local function flipCar(car) if inCar then local yRot = car:FindFirstChild("Car Weld").DriveSeat.Orientation.Y local seat = car:FindFirstChild("Car Weld").DriveSeat repeat wait() seat:FindFirstChild("BodyGyro").MaxTorque = Vector3.new(1000,0,1000) until seat.CFrame.upVector.Y < 0.3 --Mess with the 0.3 for your car. end end local function flip(Input) if Input.KeyCode == Enum.KeyCode.V then flipCar(vehicle) end end humanoid.Seated:Connect(onSit) UserInputService.InputBegan:Connect(flip)