Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

local UserInputService = game:GetService("UserInputService")

local function simulateKeyPress(key)


game:GetService("VirtualInputManager"):SendKeyEvent(true, key, false, game)
end

local function simulateKeyRelease(key)


game:GetService("VirtualInputManager"):SendKeyEvent(false, key, false, game)
end

-- Function to check if the camera controller is active


local function isCameraControllerActive()
-- Implement your logic here to check if the camera controller is active
return false -- Placeholder value, replace with your actual logic
end

-- Create UI
local gui = Instance.new("ScreenGui")
gui.IgnoreGuiInset = true
gui.Parent = game.Players.LocalPlayer.PlayerGui

local frame = Instance.new("Frame")


frame.Size = UDim2.new(0.3, 0, 0.12, 0) -- Make the frame smaller
frame.Position = UDim2.new(0.35, 0, 0.8, 0) -- Adjust position as necessary
frame.BackgroundColor3 = Color3.new(1, 1, 1)
frame.BackgroundTransparency = 0.5 -- Set transparency to 50%
frame.BorderSizePixel = 2
frame.Active = true -- Make the frame draggable
frame.Draggable = true -- Make the frame draggable
frame.Parent = gui

-- Create lock button


local lockButton = Instance.new("TextButton")
lockButton.Size = UDim2.new(0.1, 0, 0.1, 0)
lockButton.Position = UDim2.new(0.85, 0, 0.05, 0) -- Positioned above the UI
lockButton.Text = "Lock"
lockButton.TextScaled = true
lockButton.TextColor3 = Color3.new(1, 1, 1)
lockButton.BackgroundColor3 = Color3.new(0, 0, 0)
lockButton.Parent = gui
lockButton.Name = "LockButton"

-- Create lock button click event


local function toggleDraggable()
frame.Draggable = not frame.Draggable
if frame.Draggable then
lockButton.Text = "Lock"
else
lockButton.Text = "Unlock"
end
end

lockButton.Activated:Connect(function()
toggleDraggable()
end)

-- Create hold functions


local holding = {} -- Track if each key is being held down
local function keyDown(key)
if not holding[key] and not isCameraControllerActive() then
holding[key] = true
simulateKeyPress(key)
end
end

local function keyUp(key)


if holding[key] and not isCameraControllerActive() then
holding[key] = false
simulateKeyRelease(key)
end
end

-- Create buttons for Z, X, C, V, and F


local buttons = {}
local buttonKeys = {Enum.KeyCode.Z, Enum.KeyCode.X, Enum.KeyCode.C, Enum.KeyCode.V,
Enum.KeyCode.F}
local buttonLabels = {"Z", "X", "C", "V", "F"}
local buttonSpacing = 0.02

for i, key in ipairs(buttonKeys) do


local button = Instance.new("TextButton")
button.Size = UDim2.new(0.16, 0, 0.8, 0)
button.Position = UDim2.new((i - 1) * (0.16 + buttonSpacing), 0, 0, 0)
button.Text = buttonLabels[i]
button.TextScaled = true
button.TextColor3 = Color3.new(0, 1, 0)
button.BackgroundColor3 = Color3.new(0, 0, 0)
button.Parent = frame

-- Bind functions to button input events


button.MouseButton1Down:Connect(function()
keyDown(key)
end)

button.MouseButton1Up:Connect(function()
keyUp(key)
end)

buttons[key] = button
end

-- Update the UserInputService.InputBegan event to check if the camera controller


is active
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end

if input.UserInputType == Enum.UserInputType.Touch then


for key, button in pairs(buttons) do
if button:IsDescendantOf(gui) and button.AbsolutePosition.X <=
input.Position.X and input.Position.X <= button.AbsolutePosition.X +
button.AbsoluteSize.X and button.AbsolutePosition.Y <= input.Position.Y and
input.Position.Y <= button.AbsolutePosition.Y + button.AbsoluteSize.Y then
keyDown(key)
end
end
end
end)
-- Update the UserInputService.InputEnded event to check if the camera controller
is active
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch then
for key in pairs(buttons) do
keyUp(key)
end
end
end)

You might also like