local bodyGyro = script.Parent.BodyGyro
local plrs = game:GetService("Players")
local players = plrs:GetPlayers()
local part = script.Parent
local space = 30
function findClosestPlayer(position)
local root = nil
local h = nil
local fake = nil
local children = game.Workspace:GetChildren()
local space = 30
for i, v in pairs(children) do
local stuff = children[i]
if v:IsA("Model") then
local h = stuff:FindFirstChild("Humanoid")
if h then
root = stuff:FindFirstChild("HumanoidRootPart")
if root then
if (root ~= nil) and (h ~= nil) and (h.Health > 0) then
if (root.Position - position).magnitude < space then
print("work")
fake = root
end
end
end
end
end
end
return fake
end
while wait() do
local t = findClosestPlayer(part.Position)
if t ~= nil then
bodyGyro.CFrame = CFrame.new(part.Position, t.Position)
end
end
I just wanna make sure that
local stuff = children[i]
then local h = stuff:FindFirstChild(“Humanoid”)
does h = all the children that are humanoids, as it iterates through each one, so would it be stored like
h = humanoid1, humanoid2
based on how many there are??
sorry im not good at asking questions this might or might not seem confusing