Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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).

Ad

Answer this question