Ive tried to put the Mobs folder inside of workspace, it will work but it totally ruins the game. I even set the Primary parts to what it is supposed to be set to but it doesn't work. The Mobs folder is inside ServerStorage.
OUTPUT: Workspace.Tower.Towertesting:7: attempt to index nil with 'GetChildren' - Server - Towertesting:7 16:14:50.033 Stack Begin - Studio 16:14:50.033 Script 'Workspace.Tower.Towertesting', Line 7 - function FindNearestTarget - Studio - Towertesting:7 16:14:50.033 Script 'Workspace.Tower.Towertesting', Line 22 - Studio - Towertesting:22 16:14:50.033 Stack End - Studio
local Tower = script.Parent
local Mobs = workspace.PrimaryPart
local function FindNearestTarget()
local maxDistance = 15
local nearestTarget = nil
for i, target in ipairs(Mobs:GetChildren())do
local distance = (target.PrimaryPart.Position - Tower.PrimaryPart.Position).Magnitude
print (target.Name, distance)
if distance < maxDistance then
print(target.Name, "Nearest target found")
nearestTarget = target
maxDistance = distance
end
end
return nearestTarget
end
while true do
local target = FindNearestTarget()
if target then
target.Humanoid:TakeDamage(3)
end
task.wait(0.5)
end

2 comments
its you!!! from facility lockdown
I REMEMBER YOU