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

Top down camera switches to normal camera when click 'X'??

Asked by
s_21 74
6 years ago

Located below is My top down camera script, But I need it so when you click 'x' It switches back to the ROBLOX Default camera, How do I do this?

NOTE: The top down script is located in StarterPlayer > StarterPlayerScripts & Its a LocalScript

TOP DOWN SCRIPT-

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local OFFSET = Vector3.new(-5,50,0)
local FIELD_OF_VIEW = 90

local player = Players.LocalPlayer
local camera = game.Workspace.CurrentCamera

camera.FieldOfView = FIELD_OF_VIEW

local function onRenderStep()
    local character = player.Character
    if character then
        local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
        if humanoidRootPart then
            local playerPosition = humanoidRootPart.Position
            local cameraPosition = playerPosition + OFFSET
            camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
        end
    end
end

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

Answer this question