So I’ve been trying for a few hours but cannot seem to find a viable solution. I’ve tried making some events within the code to get it to run properly and set the CFrame
to the correct location but I never seem to get a result.
Goal: My goal is to get the watch and the camera to recenter on the head so that I wont have an offset where the camera is stuck 2 units to the right of my head instead of between my shoulders. I also want to make the watch on the wrist of the character visible when I go into first person so I won’t have to deal with the watch being invisible upon going into first person.
Attempts:
- I have already attempted setting a if/then statement to check when the character goes into first person to recenter the camera in the middle of the shoulders instead of stuck on the right.
- I have tried making the “if hit then” point for the camera to be set to have the xyz value to be that the x value subtracts 2 from the original position.
The values of the second line for “else
” were this:
player.Character.Humanoid.CameraOffset = Vector3.new(2, 0, -1)
- I have tried adding an event in between the
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
andv.LocalTransparencyModifier = v.Transparency
lines.
Code:
local player = game.Players.LocalPlayer
local char = player.Character
local camera = game.Workspace.CurrentCamera
local RunService = game:GetService(“RunService”)
local mouse = player:GetMouse()
local cutOffDistance = 1
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
for i, v in pairs(char:GetChildren()) do
if v:IsA(“BasePart”) and v.Name ~= “Head” and v.Name ~= “WristWatch” then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
RunService.RenderStepped:Connect(function(step)
local ray = Ray.new(player.Character.Head.Position, ((player.Character.Head.CFrame + player.Character.Head.CFrame.LookVector * 2) - player.Character.Head.Position).Position.Unit * cutOffDistance)
local ignoreList = player.Character:GetChildren()
local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
if hit then
player.Character.Humanoid.CameraOffset = Vector3.new(0, 0, -(player.Character.Head.Position - pos).magnitude)
else
player.Character.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
end
end)
Any help would be much appreciated.