local bulletModule = require(script.Parent.Bullet)
local RunService = game:GetService("RunService")
local turrentsFolder = workspace.Turrents:GetChildren()
local module = {}
local debounce = nil
function module.moveTurrent(target, humanoid)
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if humanoid.Health <= 0 and debounce then
debounce = nil
end
end)
for _, turrent in ipairs(turrentsFolder) do
if turrent and target and humanoid and not debounce then
debounce = true
connection = RunService.Heartbeat:Connect(function()
if debounce then
turrent.Gun.CFrame = CFrame.new(turrent.Gun.Position, target.Position)
else
connection:Disconnect()
end
end)
while wait(1) and debounce do
bulletModule.shootBullet(turrent.Gun)
end
else
debounce = nil
end
end
end
return module
My turrent module above, Iām all ears.