So I am trying to make a First Person system, where my camera follows the head even if it will move somewhere(for example if character crouching, camera will go down, because head moved).
Everything works fine, except this rotation problem(I don’t rly understand why it’s happening. I thought it’s because of my “head follow cursor” script, but no)
(made it with offset, so you can see better) https://gyazo.com/e7261ffa65367b209aa0fde0801480c9
I tried to solve this problem simply by setting rotation override by MovementRelative(so my character won’t follow my mouse, while walking) but it didn’t help.
Feel free to suggest anything.
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
for i, v in pairs(char:GetChildren()) do -- That part just makes char's body visible
if v:IsA("BasePart") and v.Name ~= "Head" then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local character = script.Parent
local head = character:WaitForChild("Head")
camera.CameraType = Enum.CameraType.Scriptable
local mouse = player:GetMouse()
RunService.RenderStepped:Connect(function(step) -- this is the camera changer
camera.CFrame = head.CFrame
end)
player.CameraMode = Enum.CameraMode.LockFirstPerson -- CameraMode change