I have scripted a part to fly from the characters lookvector at a certain velocity. My problem is that the damage part only works on the first part created. How do i make it so it works in all the created parts and just not the first one
here is my code:
s = game:GetService("ServerStorage") tool = script.Parent part = Instance.new("Part") player = game.Players.LocalPlayer stat = "undone" h = "nope" print("im black") tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if stat == "undone" and key == "m" then stat = "done" print(key) part.Transparency = .5 part.CanCollide = false print(mouse.hit) local float = Instance.new("BodyPosition",part) float.MaxForce = Vector3.new(0,102999,0) local f = Instance.new("Fire",part) f.Color = Color3.new(0,0,0) f.SecondaryColor = Color3.new(255,0,0) f.Heat = 25 f.Size = 30 local f1 = Instance.new("Fire",part) f1.Color = Color3.new(0,0,0) f1.SecondaryColor = Color3.new(255,0,0) f1.Heat = 25 f1.Size = 30 local f2 = Instance.new("Fire",part) f2.Color = Color3.new(0,0,0) f2.SecondaryColor = Color3.new(255,0,0) f2.Heat = 25 f2.Size = 30 local f3 = Instance.new("Fire",part) f3.Color = Color3.new(0,0,0) f3.SecondaryColor = Color3.new(255,0,0) f3.Heat = 25 local f4 = Instance.new("Fire",part) f4.Color = Color3.new(0,0,0) f4.SecondaryColor = Color3.new(255,0,0) f4.Heat = 25 f4.Size = 30 local f5 = Instance.new("Fire",part) f5.Color = Color3.new(0,0,0) f5.SecondaryColor = Color3.new(255,0,0) f5.Heat = 25 f5.Size = 30 local f6 = Instance.new("Fire",part) f6.Color = Color3.new(0,0,0) f6.SecondaryColor = Color3.new(255,0,0) f6.Heat = 25 f6.Size = 30 local f7 = Instance.new("Fire",part) f7.Color = Color3.new(0,0,0) f7.SecondaryColor = Color3.new(255,0,0) f7.Heat = 25 f7.Size = 30 local f8 = Instance.new("Fire",part) f8.Color = Color3.new(0,0,0) f8.SecondaryColor = Color3.new(255,0,0) f8.Heat = 25 f8.Size = 30 local f9 = Instance.new("Fire",part) f9.Color = Color3.new(0,0,0) f9.SecondaryColor = Color3.new(255,0,0) f9.Heat = 25 f9.Size = 30 local f10 = Instance.new("Fire",part) f10.Color = Color3.new(0,0,0) f10.SecondaryColor = Color3.new(255,0,0) f10.Heat = 25 f10.Size = 30 local f11 = Instance.new("Fire",part) f11.Color = Color3.new(0,0,0) f11.SecondaryColor = Color3.new(255,0,0) f11.Heat = 25 f11.Size = 30 local f12 = Instance.new("Fire",part) f12.Color = Color3.new(0,0,0) f12.SecondaryColor = Color3.new(255,0,0) f12.Heat = 25 f12.Size = 30 local f13 = Instance.new("Fire",part) f13.Color = Color3.new(0,0,0) f13.SecondaryColor = Color3.new(255,0,0) f13.Heat = 25 f13.Size = 30 local head = script.Parent.Parent.Head part.CFrame = player.Character.Torso.CFrame * CFrame.new(0,3,-8) part.Size = Vector3.new(10,10,10) part.Shape = "Ball" part.BrickColor = BrickColor.new("Really black") part.Velocity = player.Character.Torso.CFrame.lookVector * 120 local bod = Instance.new("BodyVelocity") bod.MaxForce = Vector3.new(30,30,30) bod.Velocity = player.Character.Torso.CFrame.lookVector * 120 part.Parent = game.Workspace bod.Parent = part wait(4) part:Remove() stat = "undone" end end) end) part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil and h == "nope" then h = "Yep" local humanoid = hit.Parent:FindFirstChild("Humanoid") humanoid:TakeDamage(99) print(hit.Parent.Name .."has lost 99 health") wait(2) h = "nope" end end)