Hi there I am trying to make a third person script (it’s basically shift lock) and have stumbled on to some issue that I have been having for a few days now and was wondering if anybody knew how to fix it.
Issue when I move my mouse it likes to reset as if I never moved it
Code:
local yAngle = 0
local xAngle = 0
local yOffset = 1
local xOffset = 2
local distance = 8
local camera = game.Workspace.CurrentCamera
local humanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
-------------------------------------------------------------------------------------------
--need help with this part
game:GetService("UserInputService").InputChanged:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseMovement then
-- Use mouse delta to increase/decrease yAngle and xAngle
-- Put the following line in a function that is called every RenderStepped
camera.CFrame = CFrame.new(humanoidRootPart.Position + Vector3.new(0, yOffset, 0))
* CFrame.Angles(0, math.rad(yAngle), 0)
* CFrame.Angles(math.rad(xAngle), 0, 0)
* CFrame.new(xOffset, 0, 8)
end
end)
-------------------------------------------------------------------------------------------
--making the mouse stay in the middle on the screen
local RunService = game:GetService"RunService"
local UserInputService = game:GetService"UserInputService"
RunService:BindToRenderStep("MouseLock",Enum.RenderPriority.Last.Value+1,function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end)