local players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local tool = script.Parent
local cam = workspace.CurrentCamera
local plr = players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local neck = char:FindFirstChild("RightHand"):FindFirstChild("RightWrist")
local y = neck.C0.Y
local active = false
tool.Equipped:Connect(function()
active = true
while true do
task.wait()
if active == true then
if neck then
local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
TweenService:Create(neck, TweenInfo.new(0.5), {
C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0),
}):Play()
end
tool.Unequipped:Connect(function()
active = false
end)
else
neck.C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, 0, 0)
end
end
end)
Try changing :FindFirstChild to :WaitForChild, and see if that solves your issue, also check if character isn’t nil
EDIT: I created a Tool with a part as a handle, and apparently it works fine with no errors, and I didn’t even change any code – just copied yours. Which line does this error come from?
local players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local tool = script.Parent
local cam = workspace.CurrentCamera
local plr = players.LocalPlayer
local active = false
tool.Equipped:Connect(function()
active = true
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local hrp = char:FindFirstChild("HumanoidRootPart")
local neck = char:FindFirstChild("RightHand"):FindFirstChild("RightWrist")
local y = neck.C0.Y
while true do
task.wait()
if active == true then
if neck and hrp then
local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
TweenService:Create(neck, TweenInfo.new(0.5), {
C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0),
}):Play()
end
tool.Unequipped:Connect(function()
active = false
end)
else
TweenService:Create(neck, TweenInfo.new(0.5), {
C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, 0, 0),
}):Play()
end
end
end
end)