Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hum = script.Parent:WaitForChild("Humanoid")
- local seat = nil
- hum.Seated:Connect(function(active, seatPart)
- seat = seatPart
- end)
- local w = false
- local s = false
- game:GetService("UserInputService").InputBegan:Connect(function(inp, processed)
- if processed then return end
- if inp.KeyCode == Enum.KeyCode.W then w = true end
- if inp.KeyCode == Enum.KeyCode.S then s = true end
- end)
- game:GetService("UserInputService").InputEnded:Connect(function(inp)
- if inp.KeyCode == Enum.KeyCode.W then w = false end
- if inp.KeyCode == Enum.KeyCode.S then s = false end
- end)
- local camera = workspace.CurrentCamera
- local mouse = game.Players.LocalPlayer:GetMouse()
- game:GetService("RunService").RenderStepped:Connect(function()
- if seat then
- camera.CameraType = Enum.CameraType.Scriptable
- camera.CFrame = seat.Parent.Camera.CFrame * CFrame.Angles(
- math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -20),
- math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -20),
- 0
- )
- seat.BodyGyro.CFrame = CFrame.new(seat.Parent.Body.Position, mouse.Hit.LookVector * 1000)
- if w then
- seat.BodyVelocity.Velocity = seat.CFrame.LookVector * 100
- elseif s then
- seat.BodyVelocity.Velocity = seat.CFrame.LookVector * -100
- else
- seat.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
- end
- else
- camera.CameraType = Enum.CameraType.Custom
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement