Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tower = script.Parent
- local mob = workspace.Grassland.Mob
- local function FindNearestTarget()
- local maxDistance = 20
- local nearestTarget = nil
- for i, target in ipairs(mob:GetChildren()) do
- local distance = (target.HumanoidRootPart.Position - tower.Position).Magnitude
- if distance < maxDistance then
- nearestTarget = target
- maxDistance = distance
- end
- end
- return nearestTarget
- end
- while true do
- local target = FindNearestTarget()
- if target then
- local soundshot = script.Parent.Shot
- soundshot:Play()
- target.Humanoid:TakeDamage(25)
- end
- task.wait(0.3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement