
KeylessUniversal

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
-- Find a random humanoid including other player characters, excluding the player's own character
local function getRandomHumanoid(excludeCharacter)
local candidates = {}
for _, model in pairs(workspace:GetChildren()) do
if model:IsA("Model") and model ~= excludeCharacter then
local humanoid = model:FindFirstChildOfClass("Humanoid")
local hrp = model:FindFirstChild("HumanoidRootPart")
if humanoid and hrp then
table.insert(candidates, model)
end
end
end
if #candidates > 0 then
return candidates[math.random(1, #candidates)]
end
return nil
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local hrp = character:WaitForChild("HumanoidRootPart")
local targetModel = getRandomHumanoid(character)
if not targetModel then
warn("No humanoid found to follow.")
return
end
local targetHRP = targetModel:FindFirstChild("HumanoidRootPart")
if not targetHRP then
warn("Target has no HumanoidRootPart.")
return
end
-- Update the character's velocity every frame to follow the target
RunService.Heartbeat:Connect(function()
if character and hrp and targetHRP and targetModel.Parent then
local direction = (targetHRP.Position - hrp.Position).Unit
hrp.Velocity = direction * 10
end
end)
end)
end)No comments yet for this script.



