67.7k Views
201 Executions
Bot Play Script is a Piggy script for Roblox, uploaded to ScriptBlox on Aug 7, 2024.
Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
Script.
Updates
Script edited: Update script
Script edited: Update script
Script edited: Update script
Script edited: Update script
Script edited: Update script
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
0Log in to join the conversation. Login
No comments yet. Be the first!






