Advertisement
KenshiOfficial

School thugs script paid

Sep 28th, 2024 (edited)
4,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. -- Create the GUI
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local gui = Instance.new("ScreenGui")
  6. gui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
  7. gui.DisplayOrder = 10
  8.  
  9. local frame = Instance.new("Frame")
  10. frame.Size = UDim2.new(0, 200, 0, 150)
  11. frame.Position = UDim2.new(0, 30, 0.5, -75)
  12. frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  13. frame.BorderSizePixel = 2
  14. frame.Parent = gui
  15.  
  16. local targetLabel = Instance.new("TextLabel")
  17. targetLabel.Size = UDim2.new(1, 0, 0, 30)
  18. targetLabel.Position = UDim2.new(0, 0, 0, 0)
  19. targetLabel.Text = "Target: None"
  20. targetLabel.BackgroundColor3 = Color3.fromRGB(200, 200, 200)
  21. targetLabel.Parent = frame
  22.  
  23. local startButton = Instance.new("TextButton")
  24. startButton.Size = UDim2.new(0, 80, 0, 30)
  25. startButton.Position = UDim2.new(0.1, 0, 0.3, 0)
  26. startButton.Text = "Start Hitting"
  27. startButton.Parent = frame
  28.  
  29. local stopButton = Instance.new("TextButton")
  30. stopButton.Size = UDim2.new(0, 80, 0, 30)
  31. stopButton.Position = UDim2.new(0.1, 0, 0.6, 0)
  32. stopButton.Text = "Stop Hitting"
  33. stopButton.Parent = frame
  34.  
  35. local scriptRunning = false
  36. local currentTarget = nil
  37. local player = Players.LocalPlayer
  38.  
  39. local function firePunchEvent(targetName)
  40. local args = {
  41. [1] = 4,
  42. [2] = workspace:WaitForChild("Characters"):WaitForChild(targetName)
  43. }
  44. ReplicatedStorage:WaitForChild("MainEvents"):WaitForChild("PUNCHEVENT"):FireServer(unpack(args))
  45. end
  46.  
  47. local function findClosestPlayer()
  48. local closestPlayer = nil
  49. local closestDistance = math.huge -- Start with a very high distance
  50.  
  51. for _, otherPlayer in pairs(Players:GetPlayers()) do
  52. if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
  53. local distance = (player.Character.HumanoidRootPart.Position - otherPlayer.Character.HumanoidRootPart.Position).magnitude
  54. if distance < closestDistance then
  55. closestDistance = distance
  56. closestPlayer = otherPlayer
  57. end
  58. end
  59. end
  60.  
  61. return closestPlayer
  62. end
  63.  
  64. local function updateTarget()
  65. local closestPlayer = findClosestPlayer()
  66. if closestPlayer then
  67. currentTarget = closestPlayer.Name
  68. targetLabel.Text = "Target: " .. currentTarget
  69. else
  70. targetLabel.Text = "Target: None"
  71. end
  72. end
  73.  
  74. startButton.MouseButton1Click:Connect(function()
  75. updateTarget() -- Update target when starting
  76. if currentTarget then
  77. scriptRunning = true
  78. while scriptRunning do
  79. firePunchEvent(currentTarget) -- Fire the punch event for the target
  80. wait(0.1) -- Adjust wait time as necessary
  81. end
  82. end
  83. end)
  84.  
  85. stopButton.MouseButton1Click:Connect(function()
  86. scriptRunning = false
  87. end)
  88.  
  89. -- Optionally, you can call updateTarget at any time to refresh the target
  90. Players.LocalPlayer:GetMouse().Button1Down:Connect(function()
  91. updateTarget() -- Update target when clicked
  92. end)
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement