Piggy
67.7k Views
201 Executions

Bot Play Script

Piggy
katakanamere2
katakanamere2Published 5
2 years ago
Please login to perform these actions:

Bot Play Script is a Piggy script for Roblox, uploaded to ScriptBlox on Aug 7, 2024.

Does it work?

No reports yet

No reports yet. Tried it? Be the first to say.

Also noticed:

Description

Script.

Updates

  1. Script edited: Update script

  2. Script edited: Update script

  3. Script edited: Update script

  4. Script edited: Update script

  5. Script edited: Update script

View Raw
local piggy = script.Parent -- Reference to PiggyBot model
local humanoid = piggy:WaitForChild("Humanoid")
local players = game:GetService("Players")
local targetPlayer = nil -- Variable to store the current target player

function findNearestPlayer()
    local nearestPlayer = nil
    local nearestDistance = math.huge -- Start with a very high number

    for _, player in pairs(players:GetPlayers()) do
        if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
            local distance = (piggy.PrimaryPart.Position - player.Character.HumanoidRootPart.Position).magnitude
            if distance < nearestDistance and player.Team.Name ~= "Piggies" then -- Exclude players on the Piggies team
                nearestDistance = distance
                nearestPlayer = player
            end
        end
    end

    return nearestPlayer
end

function chasePlayer()
    while true do
        targetPlayer = findNearestPlayer() -- Find nearest player
        if targetPlayer and targetPlayer.Character then
            local targetPosition = targetPlayer.Character.HumanoidRootPart.Position
            
            humanoid:MoveTo(targetPosition) -- Move towards the target player
        end

        wait(1) -- Wait for 1 second before checking again
    end
end

chasePlayer() -- Start chasing players when the game begins



Comments

0
Log in to join the conversation. Login
No comments yet. Be the first!

More Piggy scripts

See all
Piggy
195.1k
681
4 years ago
Key System
Piggy
135.2k
710
2 years ago
Piggy
131.4k
19.9k
3 years ago
Piggy
10
0
Approved 6 minutes ago
Piggy
105
789
Approved 5 days ago
Piggy
221
1.4k
Approved 6 days ago
Piggy
335
4.3k
Approved 1 week ago
Piggy
8.5k
89.0k
Bumped 2 weeks ago