MaxproGlitcher

Key Board Simple .lua

Feb 2nd, 2025
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1.  
  2. -- Services
  3. local Players = game:GetService("Players")
  4. local UserInputService = game:GetService("UserInputService")
  5. local TweenService = game:GetService("TweenService")
  6. local MarketplaceService = game:GetService("MarketplaceService")
  7. local CoreGui = game:GetService("CoreGui")
  8.  
  9. -- UI Elements
  10. local ScreenGui = Instance.new("ScreenGui")
  11. ScreenGui.Name = "KeystrokeUI"
  12. ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  13. ScreenGui.Parent = CoreGui
  14.  
  15. local Frame = Instance.new("Frame")
  16. Frame.Parent = ScreenGui
  17. Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  18. Frame.BackgroundTransparency = 0.4
  19. Frame.BorderSizePixel = 0
  20. Frame.Position = UDim2.new(0.77, 0, 0.15, 0)
  21. Frame.Size = UDim2.new(0, 170, 0, 170)
  22. Frame.Active = true -- for dragging
  23.  
  24. local UICorner = Instance.new("UICorner")
  25. UICorner.Parent = Frame
  26.  
  27. local UIStroke = Instance.new("UIStroke")
  28. UIStroke.Parent = Frame
  29. UIStroke.Thickness = 3
  30. UIStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  31.  
  32. -- Animate Neon RGB Stroke
  33. local function animateStroke()
  34. local hue = 0
  35. while true do
  36. UIStroke.Color = Color3.fromHSV(hue, 1, 1)
  37. hue = (hue + 0.01) % 1
  38. task.wait(0.05)
  39. end
  40. end
  41. task.spawn(animateStroke)
  42.  
  43. -- Game Name Detection
  44. local gameNameLabel = Instance.new("TextLabel")
  45. gameNameLabel.Parent = Frame
  46. gameNameLabel.Size = UDim2.new(1, 0, 0, 20)
  47. gameNameLabel.Position = UDim2.new(0, 0, -0.15, 0)
  48. gameNameLabel.BackgroundTransparency = 1
  49. gameNameLabel.Font = Enum.Font.SourceSans
  50. gameNameLabel.TextScaled = true
  51. gameNameLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  52. gameNameLabel.Text = "Loading game name..."
  53.  
  54. task.spawn(function()
  55. local success, info = pcall(function()
  56. return MarketplaceService:GetProductInfo(game.PlaceId)
  57. end)
  58. if success and info then
  59. gameNameLabel.Text = info.Name
  60. else
  61. gameNameLabel.Text = "Unknown Game"
  62. end
  63. end)
  64.  
  65. -- Key Definitions
  66. local keys = {
  67. {Name = "W", KeyCode = Enum.KeyCode.W, Position = UDim2.new(0.364, 0, 0.04, 0)},
  68. {Name = "A", KeyCode = Enum.KeyCode.A, Position = UDim2.new(0.035, 0, 0.364, 0)},
  69. {Name = "S", KeyCode = Enum.KeyCode.S, Position = UDim2.new(0.364, 0, 0.364, 0)},
  70. {Name = "D", KeyCode = Enum.KeyCode.D, Position = UDim2.new(0.688, 0, 0.364, 0)},
  71. {Name = "LMB", InputType = Enum.UserInputType.MouseButton1, Position = UDim2.new(0.035, 0, 0.664, 0), Size = UDim2.new(0, 78, 0, 25)},
  72. {Name = "RMB", InputType = Enum.UserInputType.MouseButton2, Position = UDim2.new(0.494, 0, 0.664, 0), Size = UDim2.new(0, 78, 0, 25)},
  73. {Name = "Spacebar", KeyCode = Enum.KeyCode.Space, Position = UDim2.new(0.035, 0, 0.852, 0), Size = UDim2.new(0, 156, 0, 25)}
  74. }
  75.  
  76. -- Key Buttons
  77. local buttons = {}
  78. for _, keyData in pairs(keys) do
  79. local keyButton = Instance.new("TextButton")
  80. local buttonUICorner = Instance.new("UICorner")
  81.  
  82. keyButton.Name = keyData.Name
  83. keyButton.Parent = Frame
  84. keyButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  85. keyButton.BackgroundTransparency = 0.5
  86. keyButton.BorderSizePixel = 0
  87. keyButton.Position = keyData.Position
  88. keyButton.Size = keyData.Size or UDim2.new(0, 45, 0, 45)
  89. keyButton.Font = Enum.Font.GothamBold
  90. keyButton.Text = keyData.Name
  91. keyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  92. keyButton.TextSize = 20
  93. keyButton.TextWrapped = true
  94. keyButton.AutoButtonColor = false
  95.  
  96. buttonUICorner.Parent = keyButton
  97. buttons[keyData.Name] = keyButton
  98. end
  99.  
  100. -- Long Press / Long Click Detection
  101. local longPressThreshold = 0.01
  102. local keyPressTimes = {}
  103.  
  104. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  105. if gameProcessed then return end
  106. for _, keyData in pairs(keys) do
  107. if (keyData.KeyCode and input.KeyCode == keyData.KeyCode) or
  108. (keyData.InputType and input.UserInputType == keyData.InputType) then
  109. local button = buttons[keyData.Name]
  110. if button then
  111. keyPressTimes[keyData.Name] = tick()
  112. task.spawn(function()
  113. task.wait(longPressThreshold)
  114. if keyPressTimes[keyData.Name] then
  115. TweenService:Create(button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(0, 255, 255)}):Play()
  116. end
  117. end)
  118. end
  119. end
  120. end
  121. end)
  122.  
  123. UserInputService.InputEnded:Connect(function(input, gameProcessed)
  124. if gameProcessed then return end
  125. for _, keyData in pairs(keys) do
  126. if (keyData.KeyCode and input.KeyCode == keyData.KeyCode) or
  127. (keyData.InputType and input.UserInputType == keyData.InputType) then
  128. local button = buttons[keyData.Name]
  129. if button and keyPressTimes[keyData.Name] then
  130. local pressDuration = tick() - keyPressTimes[keyData.Name]
  131. keyPressTimes[keyData.Name] = nil
  132. if pressDuration < longPressThreshold then
  133. TweenService:Create(button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(255, 255, 255)}):Play()
  134. task.wait(0.1)
  135. TweenService:Create(button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(50, 50, 50)}):Play()
  136. else
  137. TweenService:Create(button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(50, 50, 50)}):Play()
  138. end
  139. end
  140. end
  141. end
  142. end)
  143.  
  144. -- Draggify GUI Functionality for Main Frame
  145. local dragging, dragStart, startPos
  146. Frame.InputBegan:Connect(function(input)
  147. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  148. dragging = true
  149. dragStart = input.Position
  150. startPos = Frame.Position
  151. input.Changed:Connect(function()
  152. if input.UserInputState == Enum.UserInputState.End then
  153. dragging = false
  154. end
  155. end)
  156. end
  157. end)
  158.  
  159. UserInputService.InputChanged:Connect(function(input)
  160. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  161. local delta = input.Position - dragStart
  162. Frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  163. end
  164. end)
Add Comment
Please, Sign In to add comment