Hello!
I’ve got a problem regarding a helicopter that’s being added to my game, It’s got many problems to start off with and Im unable to fix the problems even after trying to debug it.
There is 2 1/2 Main problems:
-
Helicopter’s Rockets spawn to many times in one event even when its supposed to spawn one and it hits eachother.
-
The Turret on it is firing sometimes and the next its not.
-
[Also it gives this warning after spawning another helicopter
Infinite yield possible on 'AttackHelicopter_Manual_PacaTea:WaitForChild("Turret") - Line 14
]
game.ReplicatedStorage.Killstreak.Apache.ApacheInbound.OnServerEvent:Connect(function(player,check)
if check == true then
local apache = game.ReplicatedStorage.Killstreak.Apache.AttackHelicopter_Manual:Clone()
apache.Parent = workspace
apache.Name = "AttackHelicopter_Manual_"..player.Name
game.ReplicatedStorage.Killstreak.Apache.ApacheInbound:FireClient(player,"Online")
player.Character.Humanoid.Died:Connect(function()
game.Debris:AddItem(apache,0)
end)
game.ReplicatedStorage.Killstreak.Apache.FollowMouseApache.OnServerEvent:Connect(function(player,mospos)
apache:WaitForChild("Turret").PrimaryPart.CFrame = CFrame.new(apache:WaitForChild("Turret").PrimaryPart.CFrame.Position,mospos)
end)
game.ReplicatedStorage.Killstreak.Apache.FireApache.OnServerEvent:Connect(function(player)
if apache then
print("animation Serverly")
local fire = apache:WaitForChild("Turret").AnimationController:LoadAnimation(apache:WaitForChild("Turret").Barrel.Fire)
fire:Play()
local fireclonesound = apache:WaitForChild("Turret").Barrel.ShootSound:Clone()
fireclonesound:Play()
game.Debris:AddItem(fireclonesound,2)
fire:GetMarkerReachedSignal("Fire"):Connect(function()
apache:WaitForChild("Turret").Barrel.FirePart.Particles.Enabled = true
apache:WaitForChild("Turret").Barrel.Smoke.ParticleEmitter.Enabled = true
apache:WaitForChild("Turret").Barrel.FirePart.Light.Enabled = true
end)
fire:GetMarkerReachedSignal("FireEnd"):Connect(function()
apache:WaitForChild("Turret").Barrel.FirePart.Particles.Enabled = false
apache:WaitForChild("Turret").Barrel.Smoke.ParticleEmitter.Enabled = false
apache:WaitForChild("Turret").Barrel.FirePart.Light.Enabled = false
end)
end
end)
game.ReplicatedStorage.Killstreak.Apache.FireRocketApache.OnServerEvent:Connect(function(player, mospos)
local rocket = game.ReplicatedStorage.Killstreak.Apache.Rocket:Clone()
rocket.Name = "Rocket_"..player.Name
print("new rocket")
rocket.Parent = game.Workspace
rocket.PrimaryPart.CFrame = CFrame.new(rocket.PrimaryPart.Position,mospos)
local velocity = Instance.new("BodyVelocity")
velocity.MaxForce = Vector3.new(1,1,1) * 10000
velocity.Velocity = rocket.PrimaryPart.CFrame.LookVector * 500
velocity.Parent = rocket.Mainpart
game.Debris:AddItem(rocket,7.5)
rocket.Mainpart.Touched:Connect(function(part)
if part ~= rocket.Rocket then
local explosion = Instance.new("Explosion")
explosion.Parent = game.Workspace.Cloned.ClonedWeaponry.Explosion
explosion.Position = rocket.Mainpart.Position
rocket:Remove()
end
end)
end)
else
local apache = workspace:FindFirstChild("AttackHelicopter_Manual_"..player.Name)
if apache then
game.Debris:AddItem(apache,0)
end
end
end)
When you first use it:
The second time you use it:
Hopefully you can understand the situation im in right now and I wish for some help on this topic.
Thank you for reading.