hello i need help with my 51 lines of camera system, so when i toggle the Alternative move (by pressing F for the first time) it do change the Position but also the "Rotation" causing disproportion between default and alternative mode. You can test the script below:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 55
-- Settings
local default_offset = Vector3.new(0, 20, -20)
local alternative_offset = Vector3.new(0, 20, 0)
local offset = default_offset
local function onCharacterAdded(character)
local root = character:WaitForChild("HumanoidRootPart")
local renderConnection
renderConnection = RunService.RenderStepped:Connect(function()
if not root or not root.Parent then
renderConnection:Disconnect()
return end
local cameraPos = root.Position + offset
camera.CFrame = CFrame.lookAt(cameraPos, root.Position)
end)
character.AncestryChanged:Connect(function(_, parent)
if not parent then
if renderConnection then
renderConnection:Disconnect()
renderConnection = nil
end
end
end)
end
local Alternative_mode = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
Alternative_mode = not Alternative_mode
if Alternative_mode then
offset = alternative_offset
else
offset = default_offset
end
end
end)
player.CharacterAdded:Connect(onCharacterAdded)
** You are now Level 1! **