Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- free cam mobile made by @pystYT
- -- kinda bad
- local Players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Camera = game.Workspace.CurrentCamera
- local LocalPlayer = Players.LocalPlayer
- -- Create the main GUI components
- local ScreenGui = Instance.new("ScreenGui")
- local FCButton = Instance.new("TextButton")
- local ForwardButton = Instance.new("TextButton")
- local BackwardButton = Instance.new("TextButton")
- local LeftButton = Instance.new("TextButton")
- local RightButton = Instance.new("TextButton")
- -- Properties for the "FC" button
- ScreenGui.Parent = game.CoreGui
- FCButton.Parent = ScreenGui
- FCButton.Text = "FC"
- FCButton.Size = UDim2.new(0, 50, 0, 50) -- Size of the button
- FCButton.Position = UDim2.new(0.92, 0, 0.05, 0) -- Top right corner
- FCButton.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- Blue color
- FCButton.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
- FCButton.BorderSizePixel = 0
- FCButton.TextScaled = true
- -- Function to configure movement buttons
- local function configureButton(button, text, position)
- button.Text = text
- button.Size = UDim2.new(0, 50, 0, 50)
- button.Position = position
- button.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
- button.TextColor3 = Color3.fromRGB(255, 255, 255)
- button.BorderSizePixel = 0
- button.TextScaled = true
- button.Visible = false
- button.Parent = ScreenGui
- end
- -- Configure movement buttons at bottom left
- configureButton(ForwardButton, "↑", UDim2.new(0.05, 0, 0.7, 0))
- configureButton(BackwardButton, "↓", UDim2.new(0.05, 0, 0.8, 0))
- configureButton(LeftButton, "←", UDim2.new(0.00, 0, 0.75, 0))
- configureButton(RightButton, "→", UDim2.new(0.1, 0, 0.75, 0))
- -- Movement variables
- local isFreeCam = false
- local isShowingButtons = false
- local moveSpeed = 1
- local lookSpeed = 0.2
- local moveVector = Vector3.new(0, 0, 0)
- local lookVector = Vector2.new(0, 0)
- local movementDirection = Vector3.new(0, 0, 0)
- -- Toggle free camera and show/hide movement buttons
- local function toggleFreeCam()
- isFreeCam = not isFreeCam
- if isFreeCam then
- Camera.CameraType = Enum.CameraType.Scriptable
- ForwardButton.Visible = true
- BackwardButton.Visible = true
- LeftButton.Visible = true
- RightButton.Visible = true
- isShowingButtons = true
- else
- Camera.CameraType = Enum.CameraType.Custom
- ForwardButton.Visible = false
- BackwardButton.Visible = false
- LeftButton.Visible = false
- RightButton.Visible = false
- isShowingButtons = false
- end
- end
- -- Button press event listeners to control movement direction
- ForwardButton.MouseButton1Down:Connect(function()
- movementDirection = Vector3.new(0, 0, -1) -- Move forward
- end)
- ForwardButton.MouseButton1Up:Connect(function()
- movementDirection = Vector3.new(0, 0, 0)
- end)
- BackwardButton.MouseButton1Down:Connect(function()
- movementDirection = Vector3.new(0, 0, 1) -- Move backward
- end)
- BackwardButton.MouseButton1Up:Connect(function()
- movementDirection = Vector3.new(0, 0, 0)
- end)
- LeftButton.MouseButton1Down:Connect(function()
- movementDirection = Vector3.new(-1, 0, 0) -- Move left
- end)
- LeftButton.MouseButton1Up:Connect(function()
- movementDirection = Vector3.new(0, 0, 0)
- end)
- RightButton.MouseButton1Down:Connect(function()
- movementDirection = Vector3.new(1, 0, 0) -- Move right
- end)
- RightButton.MouseButton1Up:Connect(function()
- movementDirection = Vector3.new(0, 0, 0)
- end)
- -- Screen dragging for looking around
- UserInputService.TouchMoved:Connect(function(input)
- if isFreeCam then
- local delta = input.Position - input.PreviousPosition
- lookVector = Vector2.new(-delta.X, -delta.Y) * lookSpeed
- end
- end)
- -- Free cam movement logic
- RunService.RenderStepped:Connect(function()
- if isFreeCam then
- local forward = Camera.CFrame.LookVector
- local right = Camera.CFrame.RightVector
- local up = Camera.CFrame.UpVector
- -- Move the camera in the desired direction
- local moveDirection = (right * movementDirection.X + forward * movementDirection.Z).unit
- Camera.CFrame = Camera.CFrame + moveDirection * moveSpeed
- -- Look around the camera
- local angles = CFrame.Angles(lookVector.Y, lookVector.X, 0)
- Camera.CFrame = Camera.CFrame * angles
- -- Reset look vector to avoid continuous spinning
- lookVector = Vector2.new(0, 0)
- end
- end)
- -- Toggle free cam on FCButton click
- FCButton.MouseButton1Click:Connect(function()
- toggleFreeCam()
- end)
Advertisement
Add Comment
Please, Sign In to add comment