I’ve been working on a tower defense game in which the enemies can damage the towers. The problem is whenever fast enemies come into contact with towers, there is a huge delay. I’ve attached my code as well as a video of the problem. The video may appear laggy, but it was not when it was recorded.
local Enemy = Instance.new("Part", workspace)
Enemy.Name = "Brute"
Enemy.Size = Vector3.new(4, 9, 4)
Enemy.Transparency = 0.5
Enemy.Color = Color3.fromRGB(255, 0,50)
Enemy.CanCollide = false
Enemy.Anchored = true
Enemy.Position = Vector3.new(2, 4.5, -78)
local Attachment0 = Instance.new("Attachment", Enemy)
local Velocity = Instance.new("LinearVelocity", Enemy)
Velocity.Attachment0 = Attachment0
Velocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
Velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
Velocity.MaxForce = math.huge
Velocity.VectorVelocity = Vector3.new(0, 0, 50)
Enemy.Touched:Connect(function(Hit)
if Hit.Name == "Tower" then
Enemy.Anchored = true
end
end)