I’m having an issue making the camera position based off the character’s head, but also make it freely move around.
However whenever I run the game and go into first person, it spins like a fidget spinner.
--Setup--
--Services--
local Plrs = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local RS2 = game:GetService("RunService")
--Player--
local Plr = Plrs.LocalPlayer
local GUI = Plr.PlayerGui
--Remotes--
local Remotes = RS:WaitForChild("Remotes")
--Camera--
local Cam = workspace.CurrentCamera
---------
--Main Code--
repeat wait() until Plr.Character
RS2.RenderStepped:Connect(function()
if Plr.Character then
local Distance = (Plr.Character.Head.Position - Cam.CFrame.Position).Magnitude
if Distance <= 10 then
Cam.CFrame = CFrame.new(Plr.Character.Head.Position.X, Plr.Character.Head.Position.Y, Plr.Character.Head.Position.Z)
for i, v in pairs(Plr.Character:GetDescendants()) do
if v:IsA("BasePart") and v.Name ~= "Head" then
v.LocalTransparencyModifier = 0
if v.Parent:IsA("Accessory") and v.Name == "Handle" then
v.LocalTransparencyModifier = 1
end
end
end
end
end
end)
-------------
The code above is my entire script for handling the camera. And don’t worry about the range. The player will always be in First Person Lock when I’m finished with the game.