Rojhann10

Untitled

Aug 16th, 2025
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.67 KB | None | 0 0
  1. --// LocalScript inside StarterGui
  2. local Players = game:GetService("Players")
  3. local RunService = game:GetService("RunService")
  4. local UserInputService = game:GetService("UserInputService")
  5. local localPlayer = Players.LocalPlayer
  6.  
  7. -- Gui
  8. local screenGui = Instance.new("ScreenGui")
  9. screenGui.Name = "ControlGui"
  10. screenGui.ResetOnSpawn = false
  11. screenGui.Parent = localPlayer:WaitForChild("PlayerGui")
  12.  
  13. local frame = Instance.new("Frame")
  14. frame.Size = UDim2.new(0, 250, 0, 150)
  15. frame.Position = UDim2.new(0.05, 0, 0.2, 0)
  16. frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  17. frame.BackgroundTransparency = 0.2
  18. frame.Parent = screenGui
  19. frame.Active = true
  20. frame.Draggable = true
  21. Instance.new("UICorner", frame).CornerRadius = UDim.new(0, 12)
  22.  
  23. local textBox = Instance.new("TextBox")
  24. textBox.Size = UDim2.new(0.9, 0, 0, 30)
  25. textBox.Position = UDim2.new(0.05, 0, 0.1, 0)
  26. textBox.PlaceholderText = "Enter owner name"
  27. textBox.Text = ""
  28. textBox.BackgroundColor3 = Color3.new(1, 1, 1)
  29. textBox.TextColor3 = Color3.new(0, 0, 0)
  30. textBox.Parent = frame
  31. Instance.new("UICorner", textBox).CornerRadius = UDim.new(0, 8)
  32.  
  33. local button = Instance.new("TextButton")
  34. button.Size = UDim2.new(0.9, 0, 0, 40)
  35. button.Position = UDim2.new(0.05, 0, 0.4, 0)
  36. button.Text = "Get Controlled"
  37. button.BackgroundColor3 = Color3.new(1, 1, 1)
  38. button.TextColor3 = Color3.new(0, 0, 0)
  39. button.Parent = frame
  40. Instance.new("UICorner", button).CornerRadius = UDim.new(0, 8)
  41.  
  42. -- Vars
  43. local controller = nil
  44. local followConn = nil
  45. local flyConn = nil
  46. local spinConn = nil
  47. local flying = false
  48. local spinning = false
  49. local whitelist = {}
  50.  
  51. -- Utility
  52. local function findPlayerByNameOrDisplay(input)
  53. for _, plr in ipairs(Players:GetPlayers()) do
  54. if plr.Name:lower() == input:lower() or plr.DisplayName:lower() == input:lower() then
  55. return plr
  56. end
  57. end
  58. return nil
  59. end
  60.  
  61. -- Attach / Detach
  62. local function stopAttach()
  63. if followConn then
  64. followConn:Disconnect()
  65. followConn = nil
  66. end
  67. end
  68.  
  69. local function startAttach(targetPlayer)
  70. stopAttach()
  71. local myChar = localPlayer.Character or localPlayer.CharacterAdded:Wait()
  72. local myRoot = myChar:WaitForChild("HumanoidRootPart")
  73.  
  74. followConn = RunService.RenderStepped:Connect(function()
  75. local targetChar = targetPlayer.Character
  76. if targetChar and targetChar:FindFirstChild("HumanoidRootPart") and myChar.Parent then
  77. myRoot.CFrame = targetChar.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
  78. else
  79. stopAttach()
  80. end
  81. end)
  82. end
  83.  
  84. -- Fly
  85. local function startFly()
  86. if flying then return end
  87. flying = true
  88. local char = localPlayer.Character
  89. if not char then return end
  90. local hrp = char:WaitForChild("HumanoidRootPart")
  91. local hum = char:WaitForChild("Humanoid")
  92. hum.PlatformStand = true
  93.  
  94. flyConn = RunService.RenderStepped:Connect(function()
  95. local moveDir = Vector3.zero
  96. if UserInputService:IsKeyDown(Enum.KeyCode.W) then moveDir += workspace.CurrentCamera.CFrame.LookVector end
  97. if UserInputService:IsKeyDown(Enum.KeyCode.S) then moveDir -= workspace.CurrentCamera.CFrame.LookVector end
  98. if UserInputService:IsKeyDown(Enum.KeyCode.A) then moveDir -= workspace.CurrentCamera.CFrame.RightVector end
  99. if UserInputService:IsKeyDown(Enum.KeyCode.D) then moveDir += workspace.CurrentCamera.CFrame.RightVector end
  100. if moveDir.Magnitude > 0 then
  101. hrp.Velocity = moveDir.Unit * 50
  102. else
  103. hrp.Velocity = Vector3.zero
  104. end
  105. end)
  106. end
  107.  
  108. local function stopFly()
  109. if not flying then return end
  110. flying = false
  111. if flyConn then flyConn:Disconnect() flyConn = nil end
  112. local char = localPlayer.Character
  113. if char and char:FindFirstChild("Humanoid") then
  114. char.Humanoid.PlatformStand = false
  115. end
  116. end
  117.  
  118. -- Spin
  119. local function startSpin()
  120. if spinning then return end
  121. spinning = true
  122. local char = localPlayer.Character
  123. if not char then return end
  124. local hrp = char:WaitForChild("HumanoidRootPart")
  125.  
  126. spinConn = RunService.RenderStepped:Connect(function()
  127. if hrp.Parent then
  128. hrp.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(10), 0)
  129. else
  130. stopSpin()
  131. end
  132. end)
  133. end
  134.  
  135. local function stopSpin()
  136. if not spinning then return end
  137. spinning = false
  138. if spinConn then spinConn:Disconnect() spinConn = nil end
  139. end
  140.  
  141. -- Button
  142. button.MouseButton1Click:Connect(function()
  143. local name = textBox.Text
  144. local target = findPlayerByNameOrDisplay(name)
  145. if target then
  146. controller = target
  147. button.Text = "Controller set: " .. target.DisplayName
  148. else
  149. button.Text = "Player not found"
  150. end
  151. end)
  152.  
  153. -- Commands
  154. local function handleCommand(player, msg)
  155. if player ~= controller and not whitelist[player.UserId] then return end
  156. msg = msg:lower()
  157.  
  158. if msg == "!attach" and controller then
  159. startAttach(controller)
  160.  
  161. elseif msg == "!detach" then
  162. stopAttach()
  163.  
  164. elseif msg == "!reset" then
  165. local hum = localPlayer.Character and localPlayer.Character:FindFirstChildOfClass("Humanoid")
  166. if hum then hum.Health = 0 end
  167.  
  168. elseif msg == "!spin" then
  169. startSpin()
  170.  
  171. elseif msg == "!unspin" then
  172. stopSpin()
  173.  
  174. elseif msg == "!fly" then
  175. startFly()
  176.  
  177. elseif msg == "!unfly" then
  178. stopFly()
  179.  
  180. elseif msg:sub(1,6) == "!give " then
  181. local targetName = msg:sub(7)
  182. local target = findPlayerByNameOrDisplay(targetName)
  183. if target then whitelist[target.UserId] = true end
  184.  
  185. elseif msg:sub(1,8) == "!return " then
  186. local targetName = msg:sub(9)
  187. local target = findPlayerByNameOrDisplay(targetName)
  188. if target then whitelist[target.UserId] = nil end
  189. end
  190. end
  191.  
  192. -- Connect chatted
  193. local function connectPlayer(plr)
  194. plr.Chatted:Connect(function(msg)
  195. handleCommand(plr, msg)
  196. end)
  197. end
  198.  
  199. for _, plr in ipairs(Players:GetPlayers()) do
  200. connectPlayer(plr)
  201. end
  202. Players.PlayerAdded:Connect(connectPlayer)
Advertisement
Add Comment
Please, Sign In to add comment