I was making a script to loop through everything in workspace, but it only gets the baseplate.
There are others things in the workspace.
Like a spawnlocation and the characters.
But it only prints “Baseplate”
Code (Server Script)
local function FindTarget()
local target
local maxDis = maxDistance
for _, plr in pairs(workspace:GetChildren()) do
print(plr.Name)
if plr then
if plr:FindFirstChildWhichIsA("Humanoid") == nil then return end
print(plr.Name)
if requireteam then
if not teamkill then
local team = plr:FindFirstChildWhichIsA("Team")
if team ~= nil and team.TeamColor ~= script.Parent.Team.TeamColor then
local distance = (hrp.Position - plr.HumanoidRootPart.Position).Magnitude
if requiresSight then
if distance <= maxDis and CanSeeTarget(plr) then
target = plr
maxDis = distance
end
else
if distance <= maxDis then
target = plr
maxDis = distance
end
end
end
else
local team = plr:FindFirstChildWhichIsA("Team")
if team ~= nil then
local distance = (hrp.Position - plr.HumanoidRootPart.Position).Magnitude
if requiresSight then
if distance <= maxDis and CanSeeTarget(plr) then
target = plr
maxDis = distance
end
else
if distance <= maxDis then
target = plr
maxDis = distance
end
end
end
end
else
local distance = (hrp.Position - plr.HumanoidRootPart.Position).Magnitude
if requiresSight then
if distance <= maxDis and CanSeeTarget(plr) then
target = plr
maxDis = distance
end
else
if distance <= maxDis then
target = plr
maxDis = distance
end
end
end
end
end
return target
end
Nothing other than baseplate…