Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local R = require(ReplicatedStorage:WaitForChild("Resources"))
- local Lerps = R:LoadLibrary("Lerps")
- local Player = Players.LocalPlayer
- local Camera = workspace.CurrentCamera
- local Mouse = Player:GetMouse()
- local OTSSettings = {
- maxScrollOut = 25;
- minScrollOut = 5;
- defaultScrollIn = 5;
- }
- local OTSStatus = {
- scroll = (OTSSettings.defaultScrollIn - OTSSettings.minScrollOut) / (OTSSettings.maxScrollOut - OTSSettings.minScrollOut);
- pitch = 0;
- }
- local CharacterStatus, CharacterFunctions
- function GetMousePosition()
- return Vector2.new(Mouse.x, Mouse.y)
- end
- UserInputService.InputChanged:Connect(function(inputObject)
- if inputObject.UserInputType == Enum.UserInputType.MouseWheel then
- OTSStatus.scroll = math.clamp(OTSStatus.scroll + (inputObject.Position.Z / 20), 0, 1)
- end
- end)
- UserInputService.MouseIconEnabled = false
- return function(_CharacterStatus, _CharacterFunctions)
- CharacterStatus, CharacterFunctions = _CharacterStatus, _CharacterFunctions
- Camera.CameraType = Enum.CameraType.Scriptable
- repeat wait() until CharacterStatus.Character
- local character = CharacterStatus.Character
- local lastMousePosition = nil
- local testPart = Instance.new("Part", workspace)
- testPart.CFrame = character.Head.CFrame * CFrame.new(2, 2, 5)
- testPart.Anchored = true
- testPart.Color = Color3.new(1, 0, 0)
- local testDirectionPart = Instance.new("Part", workspace)
- testDirectionPart.CFrame = testPart.CFrame * CFrame.new(2, 2, 5)
- testDirectionPart.Anchored = true
- testDirectionPart.Color = Color3.new(0, 1, 0)
- character.Humanoid.AutoRotate = false
- CharacterFunctions.RenderstepFunctions["OTS"] = function()
- local curMousePosition = GetMousePosition()
- if not lastMousePosition then
- lastMousePosition = curMousePosition
- return
- end
- local mouseDelta = lastMousePosition - curMousePosition
- testPart.CFrame = testPart.CFrame * CFrame.Angles(0, mouseDelta.x / 100, 0)
- testDirectionPart.CFrame = CFrame.new(testPart.CFrame.p) * CFrame.new(2, 2, 5)-- * CFrame.fromOrientation(testPart.Rotation.x, testPart.Rotation.y, testPart.Rotation.z)
- OTSStatus.pitch = math.clamp(OTSStatus.pitch + mouseDelta.y / 100, -0.5, 0.2)
- character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.Angles(0, mouseDelta.x / 100, 0)
- Camera.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(2, 5, Lerps.number(OTSSettings.minScrollOut, OTSSettings.maxScrollOut, OTSStatus.scroll)) * CFrame.Angles(OTSStatus.pitch, 0, 0)
- lastMousePosition = curMousePosition
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement