local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local mouse = player:GetMouse() local cameraPart = nil local watching = false local placingCamera = false local attachingCamera = false --// GUI local gui = Instance.new("ScreenGui") gui.Name = "CameraGui" gui.ResetOnSpawn = false gui.Parent = player:WaitForChild("PlayerGui") local frame = Instance.new("Frame") frame.Size = UDim2.new(0, 240, 0, 200) frame.Position = UDim2.new(0, 20, 0.5, -100) frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) frame.BorderSizePixel = 0 frame.Parent = gui local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 10) corner.Parent = frame --// Create button local function createButton(text, y, color) local button = Instance.new("TextButton") button.Size = UDim2.new(1, -20, 0, 40) button.Position = UDim2.new(0, 10, 0, y) button.Text = text button.TextColor3 = Color3.new(1, 1, 1) button.TextSize = 16 button.BackgroundColor3 = color button.BorderSizePixel = 0 button.Parent = frame local buttonCorner = Instance.new("UICorner") buttonCorner.CornerRadius = UDim.new(0, 8) buttonCorner.Parent = button return button end --// Buttons local setupButton = createButton( "Set Up Camera", 10, Color3.fromRGB(50, 120, 220) ) local unanchorButton = createButton( "Unanchor Camera", 55, Color3.fromRGB(180, 100, 40) ) local attachButton = createButton( "Attach Camera", 100, Color3.fromRGB(120, 80, 180) ) local watchButton = createButton( "Watch Camera: OFF", 145, Color3.fromRGB(80, 80, 80) ) -------------------------------------------------- -- SET UP CAMERA -------------------------------------------------- setupButton.MouseButton1Click:Connect(function() placingCamera = not placingCamera attachingCamera = false if placingCamera then setupButton.Text = "TAP A PART" setupButton.BackgroundColor3 = Color3.fromRGB(220, 150, 40) else setupButton.Text = "Set Up Camera" setupButton.BackgroundColor3 = Color3.fromRGB(50, 120, 220) end end) -------------------------------------------------- -- UNANCHOR CAMERA -------------------------------------------------- unanchorButton.MouseButton1Click:Connect(function() if not cameraPart then unanchorButton.Text = "SET UP CAMERA FIRST!" task.wait(1.5) unanchorButton.Text = "Unanchor Camera" return end -- Remove existing welds for _, object in ipairs(cameraPart:GetChildren()) do if object:IsA("WeldConstraint") then object:Destroy() end end cameraPart.Anchored = false unanchorButton.Text = "Camera Unanchored!" unanchorButton.BackgroundColor3 = Color3.fromRGB(40, 170, 80) task.wait(1) unanchorButton.Text = "Unanchor Camera" unanchorButton.BackgroundColor3 = Color3.fromRGB(180, 100, 40) end) -------------------------------------------------- -- ATTACH CAMERA -------------------------------------------------- attachButton.MouseButton1Click:Connect(function() if not cameraPart then attachButton.Text = "SET UP CAMERA FIRST!" task.wait(1.5) attachButton.Text = "Attach Camera" return end attachingCamera = not attachingCamera placingCamera = false if attachingCamera then attachButton.Text = "TAP ANY PART" attachButton.BackgroundColor3 = Color3.fromRGB(220, 150, 40) else attachButton.Text = "Attach Camera" attachButton.BackgroundColor3 = Color3.fromRGB(120, 80, 180) end end) -------------------------------------------------- -- WORLD CLICK -------------------------------------------------- mouse.Button1Down:Connect(function() -------------------------------------------------- -- PLACE CAMERA -------------------------------------------------- if placingCamera then local target = mouse.Target if not target or not target:IsA("BasePart") then return end -- Delete old camera if cameraPart then cameraPart:Destroy() end -- Create camera cameraPart = Instance.new("Part") cameraPart.Name = "PlayerCamera" cameraPart.Size = Vector3.new(1, 1, 1) cameraPart.Transparency = 1 cameraPart.Anchored = true cameraPart.CanCollide = false cameraPart.CanTouch = false cameraPart.CanQuery = false cameraPart.CFrame = CFrame.new(mouse.Hit.Position) cameraPart.Parent = workspace -- Point camera toward player local character = player.Character if character then local root = character:FindFirstChild("HumanoidRootPart") if root then cameraPart.CFrame = CFrame.lookAt( mouse.Hit.Position, root.Position ) end end placingCamera = false setupButton.Text = "Camera Set!" setupButton.BackgroundColor3 = Color3.fromRGB(40, 170, 80) task.wait(1) setupButton.Text = "Set Up Camera" setupButton.BackgroundColor3 = Color3.fromRGB(50, 120, 220) return end -------------------------------------------------- -- ATTACH CAMERA -------------------------------------------------- if attachingCamera then local target = mouse.Target if not target or not target:IsA("BasePart") then return end -- Don't attach to itself if target == cameraPart then return end -- IMPORTANT: -- We NO LONGER check target.Anchored. -- Anchored AND unanchored parts are allowed. -- Remove previous welds for _, object in ipairs(cameraPart:GetChildren()) do if object:IsA("WeldConstraint") then object:Destroy() end end -- Put camera at the clicked location cameraPart.CFrame = CFrame.new(mouse.Hit.Position) -- Camera must be unanchored for welding cameraPart.Anchored = false -- Create weld local weld = Instance.new("WeldConstraint") weld.Name = "CameraAttachment" weld.Part0 = cameraPart weld.Part1 = target weld.Parent = cameraPart attachingCamera = false attachButton.Text = "Camera Attached!" attachButton.BackgroundColor3 = Color3.fromRGB(40, 170, 80) task.wait(1) attachButton.Text = "Attach Camera" attachButton.BackgroundColor3 = Color3.fromRGB(120, 80, 180) return end end) -------------------------------------------------- -- WATCH CAMERA -------------------------------------------------- watchButton.MouseButton1Click:Connect(function() if not cameraPart then watchButton.Text = "SET UP CAMERA FIRST!" task.wait(1.5) watchButton.Text = "Watch Camera: OFF" return end watching = not watching if watching then watchButton.Text = "Watch Camera: ON" watchButton.BackgroundColor3 = Color3.fromRGB(40, 170, 80) camera.CameraType = Enum.CameraType.Scriptable else watchButton.Text = "Watch Camera: OFF" watchButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80) camera.CameraType = Enum.CameraType.Custom local character = player.Character if character then local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then camera.CameraSubject = humanoid end end end end) -------------------------------------------------- -- CAMERA FOLLOW -------------------------------------------------- RunService.RenderStepped:Connect(function() if watching and cameraPart and cameraPart.Parent then camera.CFrame = cameraPart.CFrame end end) -------------------------------------------------- -- RESPAWN -------------------------------------------------- player.CharacterAdded:Connect(function(character) if not watching then local humanoid = character:WaitForChild("Humanoid") camera.CameraType = Enum.CameraType.Custom camera.CameraSubject = humanoid end end)