Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

trying to make a script that allows me to change the screen view. i dont know what wont work?

ok so basically i'm trying to change the screen view but it just simply won't work. please help me, all help is appreciated

local cameraHeight = 12
local cameraZOffset = 20
local cameraXChase = 10
local cameraSpeed = .25
 
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
 
local function setupCamera()
	camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset),
										Vector3.new(0,cameraHeight,0))
end
setupCamera()
player.CharacterAdded:connect(setupCamera)
 
local function onUpdate()
	if player.Character and player.Character:FindFirstChild('Torso') then
		local playerX = player.Character.Torso.Position.X
		local cameraX = camera.CFrame.p.X
 
		if cameraX - cameraXChase < playerX then
			camera.CFrame = camera.CFrame + Vector3.new(cameraSpeed, 0, 0)
		end
	end
end
 
RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)

and of course i'm also new to scripting . please try figuring this out

1 answer

✓ Accepted answer

I'm not the familiar with camera work, but make sure that the CameraType and CameraSubject are set up correctly. If the subject is still set to the player, then it doesn't matter what you try and set the camera to face, the player's head will always prioritise (as far as I'm aware).

This discussion is preserved as it was. New answers, comments, and votes are closed.