You can write your topic however you want, but you need to answer these questions:
Recently, i found a script that sets the camera to the head
I get this error: PointToObjectSpace is not a valid member of Vector3
I tried using CFrame instead of Vector3 but it says: expected Vector3 got CFrame
local RunService = game:GetService("RunService")
if not game.Players.LocalPlayer.Character then
return
elseif game.Players.LocalPlayer.Character:WaitForChild("Humanoid") then
if not game.Players.LocalPlayer.Character:WaitForChild("Head") then
return
end
end
RunService:BindToRenderStep("TrackHead", Enum.RenderPriority.Camera.Value, function(deltaTime)
if not game.Players.LocalPlayer.Character then
return
end
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
if Humanoid then
if not game.Players.LocalPlayer.Character:WaitForChild("Head") then
return
end
Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame + Vector3.new(0, 1.5, 0):PointToObjectSpace(game.Players.LocalPlayer.Character:WaitForChild("Head").Position), deltaTime * 20)
end
end)
The error is returning because you’re firing PointToObjectSpace on the Vector3 instead of the CFrame. All you should need to do to fix it is put parentheses around game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame + Vector3.new(0, 1.5, 0)
I did a rewrite of the script that condenses it a decent bit, which should be placed in StarterCharacterScripts:
local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")
RunService:BindToRenderStep("TrackHead", Enum.RenderPriority.Camera.Value, function(deltaTime)
humanoid.CameraOffset = humanoid.CameraOffset:Lerp((rootPart.CFrame + Vector3.new(0, 1.5, 0)):PointToObjectSpace(head.Position), deltaTime * 20)
end)