-
The tower is supposed to shoot one missile per 2 seconds.
-
Tower shoots one missile, waits 2 seconds, shoots 2 missiles, waits 2 seconds, shoots 3 missiles, and so on, with no source of the duplication found. The script for shooting the missile is almost identical to another which shoots a cannonball, which works perfectly fine.
Side note: sometimes the tower shoots one missile but at a very fast rate, instead of waiting 2 seconds, although this might just be delayed duplication.
- Looked for errors and asked on the unofficial roblox discord server for any ideas, so far got nothing leading to the answer.
Here is the excerpt from script of the working tower’s firing script:
script.Parent.InRange.Changed:Connect(function()
if script.Parent.InRange.Value == true then
while script.Parent.InRange.Value == true do
local target = script.Parent.Targ.Value
if target ~= nil then
local c = script.Parent.Variables.Projectile.Value:Clone()
c.CFrame = script.Parent.ShootPart.CFrame
c.Velocity = script.Parent.ShootPart.CFrame.LookVector * script.Parent.Variables.Velocity.Value --((target.Position - script.Parent.ShootPart.Position).Magnitude * 5)
c.Parent = workspace.ProjectileStorage
c.PlayerUsedBy.Value = script.Parent.PlacedBy.Value
c.TowerUsedBy.Value = script.Parent
script.Parent.ShootPart.Cannon:Play()
script.Parent.ShootPart.ParticleEmitter:Emit(50)
deb:AddItem(c,script.Parent.Variables.Decay.Value)
wait(script.Parent.Variables.AttackSpeed.Value)
end
wait()
end
end
end)
Here is the excerpt from script of the missile-firing tower:
script.Parent.InRange.Changed:Connect(function()
if script.Parent.InRange.Value == true then
while script.Parent.InRange.Value == true do
local target = script.Parent.Targ.Value
wait()
if target ~= nil then
local c = script.Parent.Variables.Projectile.Value:Clone()
c.CFrame = script.Parent.ShootPart.CFrame
c.Velocity = script.Parent.ShootPart.CFrame.LookVector * script.Parent.Variables.Velocity.Value
c.Parent = workspace.ProjectileStorage
c.PlayerUsedBy.Value = script.Parent.PlacedBy.Value
c.TowerUsedBy.Value = script.Parent
c.TowerTarget.Value = target
script.Parent.ShootPart.Cannon:Play()
script.Parent.ShootPart.ParticleEmitter:Emit(50)
deb:AddItem(c,script.Parent.Variables.Decay.Value)
wait(script.Parent.Variables.AttackSpeed.Value)
end
end
end
end)
Any leads or even solutions would be greatly appreciated. Thanks.