-
What do you want to achieve? I wanna remove the
task.wait(0.01)
at the end of the script because it causes delay on tower Firerate -
What is the issue? If i remove it i get a error saying something like Stack overflow
-
What solutions have you tried so far? I dont know how to fix this.
function tower.Attack(newTower, player)
local config = newTower:FindFirstChild("Config")
local target = tower.FindTarget(newTower, config.Range.Value, config.TargetMode.Value)
if target and target:FindFirstChildOfClass("Humanoid") and not config:FindFirstChild("Burst") and target.Humanoid.Health > 0 then
enemyHighlightEvent:FireAllClients(target)
if target.Humanoid.Health < config.Damage.Value then
player.Cash.Value += target.Humanoid.Health
else
player.Cash.Value += config.Damage.Value
end
if newTower.Animations.Fire:FindFirstChild("Attack") then
animateTowerEvent:FireAllClients(newTower, "Fire", "Attack", target)
elseif newTower.Animations.Fire:FindFirstChild("Attack1") and newTower.Animations.Fire:FindFirstChild("Attack2") and newTower.Animations.Fire:FindFirstChild("CurrentAnim") then
animateMultipleTowerEvent:FireAllClients(newTower, "Fire", "Attack1", "Attack2", target)
end
tower.FaceTarget(newTower, target, 0.0)
if newTower.Animations.Fire:FindFirstChild("Attack") then
animateTowerEvent:FireAllClients(newTower, "Fire", "Attack", target)
end
newTower.TotalDamage.Value += newTower.Config.Damage.Value
target.Humanoid:TakeDamage(config.Damage.Value)
if target.Humanoid.Health <= 0 then
player.Kills.Value += 1
end
task.wait(config.Firerate.Value)
end
task.wait(0.01) -- Firerate delay
if newTower and newTower.Parent then
tower.Attack(newTower, player)
end
end
this is a module script and im not going to show full script because theres alot of things