-- WASD = Move | Space = Up | Ctrl = Down -- Hold Right Mouse Button = Rotate | Shift = Faster -- X = Close GUI and stop freecam local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local ContextActionService = game:GetService("ContextActionService") local Player = Players.LocalPlayer local Camera = workspace.CurrentCamera local Enabled = false local Rotating = false local Speed = 50 local FastSpeed = 120 local Sensitivity = 0.008 local Keys = {} local Connection local SavedCameraType local SavedCameraSubject local SavedMouseBehavior local SavedMouseIconEnabled local CamPosition local Yaw = 0 local Pitch = 0 local GUI local Toggle local CloseButton local ACTION_NAME = "FreecamBlockMovement" local function BlockPlayerMovement() ContextActionService:BindActionAtPriority( ACTION_NAME, function() return Enum.ContextActionResult.Sink end, false, 3000, Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D, Enum.KeyCode.Space, Enum.KeyCode.LeftControl, Enum.KeyCode.RightControl, Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift ) end local function UnblockPlayerMovement() ContextActionService:UnbindAction(ACTION_NAME) end local function StopFreecam() Enabled = false Rotating = false table.clear(Keys) if Connection then Connection:Disconnect() Connection = nil end UnblockPlayerMovement() Camera.CameraType = SavedCameraType or Enum.CameraType.Custom Camera.CameraSubject = SavedCameraSubject UserInputService.MouseBehavior = SavedMouseBehavior or Enum.MouseBehavior.Default UserInputService.MouseIconEnabled = SavedMouseIconEnabled ~= nil and SavedMouseIconEnabled or true if Toggle then Toggle.Text = "Enable Freecam" Toggle.BackgroundColor3 = Color3.fromRGB(65, 110, 220) end end local function StartFreecam() if Enabled then return end Enabled = true SavedCameraType = Camera.CameraType SavedCameraSubject = Camera.CameraSubject SavedMouseBehavior = UserInputService.MouseBehavior SavedMouseIconEnabled = UserInputService.MouseIconEnabled local cf = Camera.CFrame CamPosition = cf.Position local x, y = cf:ToOrientation() Pitch = x Yaw = y BlockPlayerMovement() Camera.CameraType = Enum.CameraType.Scriptable Camera.CFrame = cf Toggle.Text = "Disable Freecam" Toggle.BackgroundColor3 = Color3.fromRGB(190, 65, 65) Connection = RunService.RenderStepped:Connect(function(dt) if not Enabled then return end Camera.CameraType = Enum.CameraType.Scriptable local rotation = CFrame.fromOrientation(Pitch, Yaw, 0) local move = Vector3.zero if Keys.W then move += rotation.LookVector end if Keys.S then move -= rotation.LookVector end if Keys.D then move += rotation.RightVector end if Keys.A then move -= rotation.RightVector end if Keys.Space then move += Vector3.yAxis end if Keys.LeftControl or Keys.RightControl then move -= Vector3.yAxis end local currentSpeed = (Keys.LeftShift or Keys.RightShift) and FastSpeed or Speed if move.Magnitude > 0 then CamPosition += move.Unit * currentSpeed * dt end if Rotating then local delta = UserInputService:GetMouseDelta() Yaw -= delta.X * Sensitivity Pitch = math.clamp( Pitch - delta.Y * Sensitivity, math.rad(-89), math.rad(89) ) end Camera.CFrame = CFrame.new(CamPosition) * CFrame.fromOrientation(Pitch, Yaw, 0) end) end UserInputService.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then Keys[input.KeyCode.Name] = true end if input.UserInputType == Enum.UserInputType.MouseButton2 and Enabled then Rotating = true UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition UserInputService.MouseIconEnabled = false end end) UserInputService.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard then Keys[input.KeyCode.Name] = false end if input.UserInputType == Enum.UserInputType.MouseButton2 then Rotating = false if Enabled then UserInputService.MouseBehavior = Enum.MouseBehavior.Default UserInputService.MouseIconEnabled = true end end end) -- GUI GUI = Instance.new("ScreenGui") GUI.Name = "Freecam" GUI.ResetOnSpawn = false GUI.DisplayOrder = 100 GUI.Parent = Player:WaitForChild("PlayerGui") local Frame = Instance.new("Frame") Frame.Name = "Main" Frame.Size = UDim2.fromOffset(250, 180) Frame.Position = UDim2.new(0, 25, 0.4, 0) Frame.BackgroundColor3 = Color3.fromRGB(24, 24, 30) Frame.BorderSizePixel = 0 Frame.Active = true Frame.Draggable = true Frame.Parent = GUI local function AddCorner(object, radius) local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, radius) corner.Parent = object end AddCorner(Frame, 10) local Title = Instance.new("TextLabel") Title.Size = UDim2.new(1, -55, 0, 38) Title.Position = UDim2.fromOffset(12, 0) Title.BackgroundTransparency = 1 Title.Text = "FREECAM" Title.TextColor3 = Color3.new(1, 1, 1) Title.Font = Enum.Font.GothamBold Title.TextSize = 15 Title.TextXAlignment = Enum.TextXAlignment.Left Title.Parent = Frame CloseButton = Instance.new("TextButton") CloseButton.Size = UDim2.fromOffset(30, 28) CloseButton.Position = UDim2.new(1, -36, 0, 5) CloseButton.BackgroundColor3 = Color3.fromRGB(190, 55, 65) CloseButton.Text = "X" CloseButton.TextColor3 = Color3.new(1, 1, 1) CloseButton.Font = Enum.Font.GothamBold CloseButton.TextSize = 14 CloseButton.Parent = Frame AddCorner(CloseButton, 6) Toggle = Instance.new("TextButton") Toggle.Size = UDim2.new(1, -20, 0, 38) Toggle.Position = UDim2.fromOffset(10, 43) Toggle.BackgroundColor3 = Color3.fromRGB(65, 110, 220) Toggle.Text = "Enable Freecam" Toggle.TextColor3 = Color3.new(1, 1, 1) Toggle.Font = Enum.Font.GothamBold Toggle.TextSize = 14 Toggle.Parent = Frame AddCorner(Toggle, 7) local Info = Instance.new("TextLabel") Info.Size = UDim2.new(1, -20, 0, 75) Info.Position = UDim2.fromOffset(10, 88) Info.BackgroundTransparency = 1 Info.Text = "WASD: Move camera\nSpace / Ctrl: Up / Down\nHold RMB: Rotate camera\nShift: Faster" Info.TextColor3 = Color3.fromRGB(190, 190, 200) Info.Font = Enum.Font.Gotham Info.TextSize = 12 Info.TextXAlignment = Enum.TextXAlignment.Left Info.TextYAlignment = Enum.TextYAlignment.Top Info.Parent = Frame Toggle.MouseButton1Click:Connect(function() if Enabled then StopFreecam() else StartFreecam() end end) CloseButton.MouseButton1Click:Connect(function() StopFreecam() GUI:Destroy() end) Player.CharacterAdded:Connect(function() if Enabled then StopFreecam() end end)