Im trying to make it where the camera is locked to the players head so it follows it in animations.
I have tried a few player modules which have worked but when I go out of studio and into the actual Roblox client, it glitches like shown below:
I can’t move my character and the camera is fixed in one spot and cant be moved…
if some can help me with this, it will be greatly appreciated.
Thank you!
Interesting, seems like something you would do in battlegrounds game, I would use RunService to set the camera’s position to the head’s position after every renderstep. Something like this:
Issue: the game immediately tries to set the character variable so its becomes nil
I have tried to use WaitForChild but that just yields everything forerver, how would i fix this?
-- LOCAL SCRIPT --
-- game > StarterPlayer > StarterCharacterScripts --
-- or
-- game > StarterGui --
task.wait(.5)
local run = game:GetService("RunService")
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")
run:BindToRenderStep("CamOffset",Enum.RenderPriority.Camera.Value + 1,function()
if hum.CameraOffset ~= (hrp.CFrame + Vector3.new(0, 1.5, 0)):ToObjectSpace(head.CFrame).Position then
hum.CameraOffset = (hrp.CFrame + Vector3.new(0, 1.5, 0)):ToObjectSpace(head.CFrame).Position
end
end)