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

How do I change camera position and make it work afterwards?

Asked by 6 years ago
Edited 6 years ago

So I have this script to move the camera to a specific part I want:

local Camera = workspace.CurrentCamera
Camera.CameraType = "Scriptable"
for i = 0,1,.001 do --// Our own Tween function
    wait()
        Camera.CFrame = Camera.CFrame:lerp(workspace.Cam2.CFrame,i)
end

but now if I want to make it go back the camera gets stuck! full script:

local infield = false
local viewing = false
script.Parent.Touched:Connect(function(hit) 
    local player = game.Players:GetPlayerFromCharacter(hit.Parent) 
    script.Parent.BillboardGui.Enabled=true
    infield=true
    function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
        if infield then
            if viewing then
                local Camera = workspace.CurrentCamera
                script.Parent.BillboardGui.Enabled=false
                Camera.CameraType = "Custom"
                Camera.FieldOfView = 20
                for i = 0,1,.001 do --// Our own Tween function
                    wait()
                    Camera.CFrame = Camera.CFrame:lerp(Camera.CameraSubject,i)
                end
            else
                viewing=true
                script.Parent.BillboardGui.Enabled=false
                local Camera = workspace.CurrentCamera
                Camera.CameraType = "Scriptable"
                for i = 0,1,.001 do --// Our own Tween function
                    wait()
                    Camera.CFrame = Camera.CFrame:lerp(workspace.Cam2.CFrame,i)
                end
            end
        end
    end
end
end)

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

errors: none.

0
If you are using filtering enablrd UserInputService should be acessed from a localscript Simnico99 206 — 6y
0
It works fine for me probs because of filtering enabled being disabled but I just need to know how to reverse the moving of the cam! now it gets stuck when u try to go back DanielDeJong3 158 — 6y
0
I can't quite tell completely what is happening here, but my best guess would be to put the camera mode back to "Custom". Garfanzo 30 — 6y
0
If you would have red the first 12 lines you would have seen I put it back to custom :/ DanielDeJong3 158 — 6y

Answer this question