local CameraController = {} local ReplicatedStorage = game:GetService("ReplicatedStorage") local camera = workspace.Camera local MAX_DIST = 40 local canMove = false local cameraPart function CameraController.WideMapView() local map = workspace.Map:WaitForChild("Map") if not map then print("lol") return end cameraPart = map:WaitForChild("CameraPart") if not cameraPart then print("lolipop") return end camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = cameraPart.CFrame canMove = true end local state = { X_Increment = 0, Y_Increment = 0, Z_Increment = 0 } local SPEED = 30 local axis = {"X","Y","Z"} function update(dt) if not canMove then return end local frame = camera.CFrame local movement = Vector3.new( state.X_Increment * dt * SPEED, state.Y_Increment * dt * SPEED, state.Z_Increment * dt * SPEED ) local newPos = frame.Position + movement local x, y, z = frame:ToOrientation() for i,v in pairs(axis) do if math.abs(newPos[v] - cameraPart.Position[v]) > MAX_DIST then return end end camera.CFrame = CFrame.new(newPos) * CFrame.Angles(x, y, z) end local uis = game:GetService("UserInputService") function InputBegan(input : InputObject) if input.KeyCode == Enum.KeyCode.A then state.X_Increment = 1 end if input.KeyCode == Enum.KeyCode.D then state.X_Increment = -1 end -- Y axis (was W/S, now Q/E) if input.KeyCode == Enum.KeyCode.Q then state.Y_Increment = -1 end if input.KeyCode == Enum.KeyCode.E then state.Y_Increment = 1 end -- Z axis (new: W/S) if input.KeyCode == Enum.KeyCode.W then state.Z_Increment = 1 end if input.KeyCode == Enum.KeyCode.S then state.Z_Increment = -1 end end function InputEnded(input : InputObject) if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then state.X_Increment = 0 end if input.KeyCode == Enum.KeyCode.Q or input.KeyCode == Enum.KeyCode.E then state.Y_Increment = 0 end if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S then state.Z_Increment = 0 end end function CameraController.ResetCamera() camera.CameraType = Enum.CameraType.Custom camera.CameraSubject = game:GetService("Players").LocalPlayer.Character:FindFirstChildOfClass("Humanoid") canMove = false end function CameraController:Init() uis.InputBegan:Connect(InputBegan) uis.InputEnded:Connect(InputEnded) game:GetService("RunService").Heartbeat:Connect(update) end return CameraController