--// DELTA EXECUTOR
--// Virtual Keyboard by vinxz 201 (Edited Final + X CLOSE)
local VIM = game:GetService("VirtualInputManager")
local UIS = game:GetService("UserInputService")
local CoreGui = game:GetService("CoreGui")
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
pcall(function()
CoreGui:FindFirstChild("vinxzUI"):Destroy()
end)
local gui = Instance.new("ScreenGui")
gui.Name = "vinxzUI"
gui.Parent = CoreGui
gui.ResetOnSpawn = false
local unlocked = false
local btnSize = 60
local defaultPos = UDim2.new(0,20,1,-190)
--==============================
-- CREATE BUTTON
--==============================
local function NewButton(text,size,pos,parent)
local b = Instance.new("TextButton")
b.Parent = parent
b.Size = size
b.Position = pos
b.BackgroundColor3 = Color3.fromRGB(30,30,30)
b.TextColor3 = Color3.fromRGB(255,255,255)
b.TextScaled = true
b.Font = Enum.Font.SourceSansBold
b.Text = text
b.BorderSizePixel = 0
return b
end
-- START BUTTON
local start = NewButton(
"CLICK HERE\nby vinxz 201",
UDim2.new(0,150,0,55),
UDim2.new(1,-160,1,-65),
gui
)
-- MAIN FRAME
local frame = Instance.new("Frame")
frame.Parent = gui
frame.Size = UDim2.new(0,430,0,170)
frame.Position = defaultPos
frame.BackgroundTransparency = 1
frame.Visible = false
-- KEYBOARD
local W = NewButton("W",UDim2.new(0,60,0,60),UDim2.new(0,70,0,0),frame)
local A = NewButton("A",UDim2.new(0,60,0,60),UDim2.new(0,0,0,70),frame)
local S = NewButton("S",UDim2.new(0,60,0,60),UDim2.new(0,70,0,70),frame)
local D = NewButton("D",UDim2.new(0,60,0,60),UDim2.new(0,140,0,70),frame)
local Space = NewButton("SPACE",UDim2.new(0,180,0,60),UDim2.new(0,230,0,70),frame)
-- SETTINGS
local setting = NewButton("⚙",UDim2.new(0,45,0,45),UDim2.new(1,-55,0,10),gui)
setting.Visible = false
-- MENU
local menu = Instance.new("Frame")
menu.Parent = gui
menu.Size = UDim2.new(0,150,0,290)
menu.Position = UDim2.new(1,-160,0,60)
menu.BackgroundColor3 = Color3.fromRGB(20,20,20)
menu.Visible = false
local lockBtn = NewButton("LOCK",UDim2.new(0,130,0,35),UDim2.new(0,10,0,10),menu)
local unlockBtn = NewButton("UNLOCK",UDim2.new(0,130,0,35),UDim2.new(0,10,0,50),menu)
local plusBtn = NewButton("+",UDim2.new(0,130,0,35),UDim2.new(0,10,0,90),menu)
local minusBtn = NewButton("-",UDim2.new(0,130,0,35),UDim2.new(0,10,0,130),menu)
local resetBtn = NewButton("RESET",UDim2.new(0,130,0,35),UDim2.new(0,10,0,170),menu)
local returnBtn = NewButton("RETURN",UDim2.new(0,130,0,35),UDim2.new(0,10,0,210),menu)
local closeBtn = NewButton("X CLOSE",UDim2.new(0,130,0,35),UDim2.new(0,10,0,250),menu)
--==============================
-- UPDATE SIZE
--==============================
local function UpdateSize()
W.Size = UDim2.new(0,btnSize,0,btnSize)
A.Size = UDim2.new(0,btnSize,0,btnSize)
S.Size = UDim2.new(0,btnSize,0,btnSize)
D.Size = UDim2.new(0,btnSize,0,btnSize)
Space.Size = UDim2.new(0,btnSize*3,0,btnSize)
W.Position = UDim2.new(0,btnSize+10,0,0)
A.Position = UDim2.new(0,0,0,btnSize+10)
S.Position = UDim2.new(0,btnSize+10,0,btnSize+10)
D.Position = UDim2.new(0,(btnSize*2)+20,0,btnSize+10)
Space.Position = UDim2.new(0,(btnSize*3)+40,0,btnSize+10)
end
--==============================
-- TOUCH DATA
--==============================
local activeTouches = {}
local function PressKey(key)
VIM:SendKeyEvent(true,key,false,game)
end
local function ReleaseKey(key)
VIM:SendKeyEvent(false,key,false,game)
end
--==============================
-- OPEN UI
--==============================
start.MouseButton1Click:Connect(function()
start.Visible = false
frame.Visible = true
setting.Visible = true
end)
setting.MouseButton1Click:Connect(function()
menu.Visible = not menu.Visible
end)
lockBtn.MouseButton1Click:Connect(function()
unlocked = false
end)
unlockBtn.MouseButton1Click:Connect(function()
unlocked = true
end)
plusBtn.MouseButton1Click:Connect(function()
btnSize = math.min(100, btnSize + 10)
UpdateSize()
end)
minusBtn.MouseButton1Click:Connect(function()
btnSize = math.max(30, btnSize - 10)
UpdateSize()
end)
-- RESET = JOYSTICK NORMAL
resetBtn.MouseButton1Click:Connect(function()
frame.Visible = false
menu.Visible = false
setting.Visible = false
start.Visible = true
frame.Position = defaultPos
btnSize = 60
UpdateSize()
for touch,key in pairs(activeTouches) do
ReleaseKey(key)
activeTouches[touch] = nil
end
pcall(function()
local player = Players.LocalPlayer
local PlayerModule = require(player.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
Controls:Enable()
Controls:SwitchToTouchControls()
end)
pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,true)
end)
end)
-- RETURN = KEMBALI WASD
returnBtn.MouseButton1Click:Connect(function()
start.Visible = false
frame.Visible = true
setting.Visible = true
menu.Visible = false
end)
-- X CLOSE = keluar total ke awal
closeBtn.MouseButton1Click:Connect(function()
frame.Visible = false
menu.Visible = false
setting.Visible = false
start.Visible = true
frame.Position = defaultPos
btnSize = 60
UpdateSize()
for touch,key in pairs(activeTouches) do
ReleaseKey(key)
activeTouches[touch] = nil
end
pcall(function()
local player = Players.LocalPlayer
local PlayerModule = require(player.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
Controls:Enable()
Controls:SwitchToTouchControls()
end)
pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,true)
end)
end)
--==============================
-- DRAG
--==============================
local dragging = false
local dragStart,startPos
frame.InputBegan:Connect(function(input)
if unlocked and input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = frame.Position
end
end)
UIS.InputChanged:Connect(function(input)
if dragging and unlocked and input.UserInputType == Enum.UserInputType.Touch then
local delta = input.Position - dragStart
frame.Position = UDim2.new(
startPos.X.Scale,
startPos.X.Offset + delta.X,
startPos.Y.Scale,
startPos.Y.Offset + delta.Y
)
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch then
dragging = false
end
end)
--==============================
-- TOUCH BUTTONS
--==============================
local function BindTouch(btn,key)
btn.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch then
activeTouches[input] = key
PressKey(key)
end
end)
btn.InputEnded:Connect(function(input)
if activeTouches[input] == key then
activeTouches[input] = nil
ReleaseKey(key)
end
end)
end
UIS.TouchMoved:Connect(function(touch)
local pos = touch.Position
local buttons = {W,A,S,D,Space}
local map = {
[W]=Enum.KeyCode.W,
[A]=Enum.KeyCode.A,
[S]=Enum.KeyCode.S,
[D]=Enum.KeyCode.D,
[Space]=Enum.KeyCode.Space
}
local found = nil
for _,btn in pairs(buttons) do
local p = btn.AbsolutePosition
local s = btn.AbsoluteSize
if pos.X >= p.X and pos.X <= p.X+s.X and
pos.Y >= p.Y and pos.Y <= p.Y+s.Y then
found = map[btn]
break
end
end
local old = activeTouches[touch]
if old ~= found then
if old then
ReleaseKey(old)
end
if found then
PressKey(found)
activeTouches[touch] = found
else
activeTouches[touch] = nil
end
end
end)
UIS.TouchEnded:Connect(function(touch)
local old = activeTouches[touch]
if old then
ReleaseKey(old)
activeTouches[touch] = nil
end
end)
BindTouch(W,Enum.KeyCode.W)
BindTouch(A,Enum.KeyCode.A)
BindTouch(S,Enum.KeyCode.S)
BindTouch(D,Enum.KeyCode.D)
BindTouch(Space,Enum.KeyCode.Space)
Comments
No comments yet
Be the first to share your thoughts!