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

Camera.CFrame is only changing the Z Value?

For some reason it is only changing the Z-Value of my Camera not the X-Value that I am trying to change.

local increment = 0
local Camera = workspace.CurrentCamera
local focusPoint = workspace.Part


-- This is inside a function
Camera.CFrame = CFrame.new(focusPoint.Position + Vector3.new(increment, 0, 0))
increment = (increment + 12.5)

9 comments

0

I'm new at this as well but try Camera.CFrame = CFrame.new(focusPoint.CFrame.lookVector*1 + Vector3.new(increment, 0, 0))

0

The Z value in your camera would be 'zoom in and zoom out'

0

Use Camera.CameraType = Enum.CameraType.Scriptable and see what happens. And put the LocalScript in StarterCharacterScripts

0

The changing to Enum really doesn't change anything but make it more stable. I need my camera to move to the right when I access this function

0

Did you try what I asked..?

0

Yeah bro it didn't work man it does the same thing

0

Can you explain exactly what you're trying to accomplish?

0

Well it's a local script and there's a gui button that you click and it brings the camera to the right aka the next item in a shop, so only the x-position of the camera is supposed to move but it zooms out only. Basically doing the camera system for the shop that Mining Simulator and other games have.

0

Ok I understand posting answer

1 answer

Haven't tested this but if theres any errors you can probably figure it out.

wait(2)
local increment = 0
local Camera = workspace.CurrentCamera
Camera.CameraType = 'Scriptable' -- This needs to be set to scriptable because roblox default camera doesn't let you change CFrrame
local focusPoint = workspace.Part

offset = focusPoint.CFrame.lookVector*-20 -- places 20 in front of part

Camera.CFrame = focusPoint.CFrame+offset


wait(2)

increment = (increment + 12.5)
-- This is inside a function
Camera:Interpolate(focusPoint.CFrame + Vector3.new(increment, 0, 0)+offset,focusPoint.CFrame,2) -- represents pan time

-- also instead of using increments, use a new focuspoint so that the angle changes as well

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