Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local combatEvent = player.Character:WaitForChild("Combat"):WaitForChild("Remote"):WaitForChild("Combat_Event")
- -- Get the player's level
- local level = player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Level").Value
- -- Automatically equip the "combat" item
- local function equipCombatItem()
- local backpack = player:WaitForChild("Backpack")
- local combatItem = backpack:FindFirstChild("combat")
- if combatItem then
- local humanoid = player.Character:WaitForChild("Humanoid")
- if humanoid then
- humanoid:EquipTool(combatItem)
- end
- else
- warn("Item 'combat' not found in the backpack.")
- end
- end
- -- Find the next Thug in the game
- local function findNextThug()
- for _, v in pairs(game.Workspace.NPCs.Thug:GetDescendants()) do
- if v:IsA("Model") and v.Name == "Thug" then
- return v
- end
- end
- return nil
- end
- -- Apply damage to the Thug
- local function applyDamage(thug, damage)
- local thugHumanoid = thug:FindFirstChild("Humanoid")
- if thugHumanoid then
- thugHumanoid:TakeDamage(damage)
- end
- end
- -- Add or update the visible hitbox
- local function addOrUpdateHitbox(thug)
- local hitbox = thug:FindFirstChild("Hitbox")
- if not hitbox then
- hitbox = Instance.new("Part")
- hitbox.Name = "Hitbox"
- hitbox.Size = Vector3.new(50, 50, 50)
- hitbox.Anchored = true
- hitbox.CanCollide = false
- hitbox.BrickColor = BrickColor.new("Bright red")
- hitbox.Material = Enum.Material.SmoothPlastic
- hitbox.Transparency = 0.5
- hitbox.Parent = thug
- end
- hitbox.Position = thug.PrimaryPart.Position
- end
- -- Reposition the player near the Thug
- local function repositionPlayer(thug, teleportPoint)
- humanoidRootPart.CFrame = CFrame.new(teleportPoint, thug.PrimaryPart.Position)
- end
- -- Interact with the Thug
- local function interactWithThug(thug)
- local thugHumanoid = thug:WaitForChild("Humanoid")
- local teleportPoint = thug.PrimaryPart.Position + Vector3.new(0, 5, 0)
- -- Add or update the visible hitbox
- addOrUpdateHitbox(thug)
- -- Reposition the player
- repositionPlayer(thug, teleportPoint)
- -- Monitor the Thug's health and interact with the next Thug
- local connection
- connection = game:GetService("RunService").Heartbeat:Connect(function()
- if thugHumanoid.Health <= 0 then
- connection:Disconnect()
- local nextThug = findNextThug()
- if nextThug then
- interactWithThug(nextThug)
- else
- print("No more Thugs found")
- end
- return
- end
- -- Update the hitbox and player position
- repositionPlayer(thug, teleportPoint)
- addOrUpdateHitbox(thug)
- end)
- -- Add a touch event to the hitbox
- local hitbox = thug:FindFirstChild("Hitbox")
- if hitbox then
- hitbox.Touched:Connect(function(hit)
- if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == player.Name then
- local args = {
- [1] = {
- [1] = thug:FindFirstChild("Humanoid")
- }
- }
- combatEvent:FireServer(unpack(args))
- end
- end)
- end
- end
- -- Check the player's level and start interaction if appropriate
- if level <= 14 then
- equipCombatItem()
- local firstThug = findNextThug()
- if firstThug then
- print("Starting interaction with first Thug")
- interactWithThug(firstThug)
- else
- print("No Thugs found")
- end
- else
- warn("Level too high to interact with Thugs.")
- end
Advertisement
Add Comment
Please, Sign In to add comment