Here's my first block to force a certain perspective (top-down)
--Creates a top-down camera for each player. Should be used as a LocalScript
local reset = false
--Get service needed for events used in this script
local RunService = game:GetService("RunService")
-- Variables for the camera and player
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
-- Constant variable used to set the camera’s offset from the player
local CAMERA_OFFSET = Vector3.new(-1,22,0)
-- Enables the camera to do what this script says
camera.CameraType = Enum.CameraType.Scriptable
-- Called every time the screen refreshes
local function onRenderStep()
-- Check the player's character has spawned
if player.Character then
local playerPosition = player.Character.HumanoidRootPart.Position
local cameraPosition = playerPosition + CAMERA_OFFSET
-- make the camera follow the player
camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
This works perfectly on it's own, however, when I use this script to force a first person perspective (in an attempt to override the first script)
game.Players.LocalPlayer.CameraMode = "Classic"
fp = false
game.Players.LocalPlayer.CameraMaxZoomDistance = 22
game.Players.LocalPlayer.CameraMinZoomDistance = 22
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(k)
if k == "e" then
if fp == false then
local CAMERA_OFFSET = Vector3.new(-1,22,0)
game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
fp = true
elseif k == "e" then
if fp then
game.Players.LocalPlayer.CameraMode = "Classic"
fp = false
end
end
end
end)
... It fails to change the perspective at all. Instead my character vanishes.
How do I take the perspective granted by the first script but ALSO have it change to a DIFFERENT first person perspective on key press?
