Ameno__GodOH

gpf

Aug 13th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character or player.CharacterAdded:Wait()
  3. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  4. local combatEvent = player.Character:WaitForChild("Combat"):WaitForChild("Remote"):WaitForChild("Combat_Event")
  5.  
  6. -- Get the player's level
  7. local level = player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Level").Value
  8.  
  9. -- Automatically equip the "combat" item
  10. local function equipCombatItem()
  11. local backpack = player:WaitForChild("Backpack")
  12. local combatItem = backpack:FindFirstChild("combat")
  13. if combatItem then
  14. local humanoid = player.Character:WaitForChild("Humanoid")
  15. if humanoid then
  16. humanoid:EquipTool(combatItem)
  17. end
  18. else
  19. warn("Item 'combat' not found in the backpack.")
  20. end
  21. end
  22.  
  23. -- Find the next Thug in the game
  24. local function findNextThug()
  25. for _, v in pairs(game.Workspace.NPCs.Thug:GetDescendants()) do
  26. if v:IsA("Model") and v.Name == "Thug" then
  27. return v
  28. end
  29. end
  30. return nil
  31. end
  32.  
  33. -- Apply damage to the Thug
  34. local function applyDamage(thug, damage)
  35. local thugHumanoid = thug:FindFirstChild("Humanoid")
  36. if thugHumanoid then
  37. thugHumanoid:TakeDamage(damage)
  38. end
  39. end
  40.  
  41. -- Add or update the visible hitbox
  42. local function addOrUpdateHitbox(thug)
  43. local hitbox = thug:FindFirstChild("Hitbox")
  44. if not hitbox then
  45. hitbox = Instance.new("Part")
  46. hitbox.Name = "Hitbox"
  47. hitbox.Size = Vector3.new(50, 50, 50)
  48. hitbox.Anchored = true
  49. hitbox.CanCollide = false
  50. hitbox.BrickColor = BrickColor.new("Bright red")
  51. hitbox.Material = Enum.Material.SmoothPlastic
  52. hitbox.Transparency = 0.5
  53. hitbox.Parent = thug
  54. end
  55. hitbox.Position = thug.PrimaryPart.Position
  56. end
  57.  
  58. -- Reposition the player near the Thug
  59. local function repositionPlayer(thug, teleportPoint)
  60. humanoidRootPart.CFrame = CFrame.new(teleportPoint, thug.PrimaryPart.Position)
  61. end
  62.  
  63. -- Interact with the Thug
  64. local function interactWithThug(thug)
  65. local thugHumanoid = thug:WaitForChild("Humanoid")
  66. local teleportPoint = thug.PrimaryPart.Position + Vector3.new(0, 5, 0)
  67.  
  68. -- Add or update the visible hitbox
  69. addOrUpdateHitbox(thug)
  70.  
  71. -- Reposition the player
  72. repositionPlayer(thug, teleportPoint)
  73.  
  74. -- Monitor the Thug's health and interact with the next Thug
  75. local connection
  76. connection = game:GetService("RunService").Heartbeat:Connect(function()
  77. if thugHumanoid.Health <= 0 then
  78. connection:Disconnect()
  79. local nextThug = findNextThug()
  80. if nextThug then
  81. interactWithThug(nextThug)
  82. else
  83. print("No more Thugs found")
  84. end
  85. return
  86. end
  87.  
  88. -- Update the hitbox and player position
  89. repositionPlayer(thug, teleportPoint)
  90. addOrUpdateHitbox(thug)
  91. end)
  92.  
  93. -- Add a touch event to the hitbox
  94. local hitbox = thug:FindFirstChild("Hitbox")
  95. if hitbox then
  96. hitbox.Touched:Connect(function(hit)
  97. if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == player.Name then
  98. local args = {
  99. [1] = {
  100. [1] = thug:FindFirstChild("Humanoid")
  101. }
  102. }
  103. combatEvent:FireServer(unpack(args))
  104. end
  105. end)
  106. end
  107. end
  108.  
  109. -- Check the player's level and start interaction if appropriate
  110. if level <= 14 then
  111. equipCombatItem()
  112. local firstThug = findNextThug()
  113. if firstThug then
  114. print("Starting interaction with first Thug")
  115. interactWithThug(firstThug)
  116. else
  117. print("No Thugs found")
  118. end
  119. else
  120. warn("Level too high to interact with Thugs.")
  121. end
Advertisement
Add Comment
Please, Sign In to add comment