21:30:06.346 - Workspace.Part.Part.Script:17: attempt to compare userdata and number
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Bullet = ReplicatedStorage:WaitForChild("Bullet")
local turrent = script.Parent
local Firerate = 0.2
local BulletDamage = 1
local BulletSpeed = 200
local AggroDistance = 100
local target
while wait(Firerate)do
local target = nil
for i, v in pairs (game.Workspace:GetChildren()) do
local humanoid = v:FindFirstChild("Humanoid")
local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
if humanoid and HumanoidRootPart and humanoid.Health > 0 then
if (HumanoidRootPart.Position - turrent.Position) < AggroDistance then
humanoid = target
end
end
end
end
