I already have the camera locked on the player, and the player rotating with the camera, but I cannot seem to figure out how to get the camera to be slightly above the player’s head, while still maintaining control over zoom level and movement.
You’re on the right track, just remove .Position on the first line since Position isn’t a valid property of camera and therefore can’t be assigned to. If you want to modify the position you have to set it’s CFrame. Also, not sure if you’ve done this or not but make sure this is wrapped in a RenderStepped event.
local baseCamPos = cam.CFrame
baseCamPos = baseCamPos + Vector3.new(0,5,0)
I would imagine that you are saying do something like this, but it doesn’t seem to work.
local baseCamPos = cam.CFrame
game:GetService("RunService").RenderStepped:Connect(function()
if baseCamPos == baseCamPos then
baseCamPos = baseCamPos + Vector3.new(0,5,0)
end
end)
What @HollowMariofan said might actually be the better solution for this particular issue so that you can keep whatever cameratype you want without having to mess with the cameratype at all. Didn’t even know that that propety existed.
But if you kept it Custom the player would still be able to spin around without turning the camera, which is not what the first gyazo video shows.
That first video has the camera firmly attached to the player which is why I pointed out the Attach CameraType.
game:GetService("RunService").RenderStepped:Connect(function()
if plr.Character then
local rootPart = plr.Character:WaitForChild("HumanoidRootPart")
if rootPart then
rootPart.CFrame = CFrame.new(rootPart.CFrame.p, rootPart.CFrame.p + Vector3.new(cam.CFrame.LookVector.X,0,cam.CFrame.LookVector.Z))
end
end
end)
So this is only my 3rd day coding and I don’t know that much about it;
I would do something like this?
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local camOffSet = humanoid.CameraOffset
local function onCharacterAdded(character)
camOffSet = Vector3.new(0,5,0)
end
Setting camOffset to humanoid’s CameraOffset creates a local variable that won’t tamper with anything outside of the script. In order to change that property, you’ll have to set it directly:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onCharacterAdded()
humanoid.CameraOffset = Vector3.new(0, 5, 0)
end
Make sure this is a LocalScript, too. Is this the entirety of your code or is this just a chunk & you call onCharacterAdded somewhere else in the script?
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onCharacterAdded()
humanoid.CameraOffset = Vector3.new(0, 5, 0)
end
However, the CameraOffset does not seem to be moving:
Ah, my apologies; I thought you were just sending me a small chunk of your completed code.
You’ll have to “call” that function because that code is stored & idling in a memory address. However, I think it would be best to remove the function block and instead just have that code run at startup:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.CameraOffset = Vector3.new(0, 5, 0)
There’s certain things I would do different in terms of syntax use, but I’ll leave those things out for now. The code above should run as intended.
Addressing what @Scottifly added: yes, you would need to change the CameraType upon respawn but I’m under the assumption that you have the actual character-locked-to-camera ordeal down.