You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make it so the bullet can pierce though multiple enemies -
What is the issue? Include screenshots / videos if possible!
even though I check it doesnt work, only pierces 1 and disappears -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
tried a bunch of stuff that had no effect on it
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that itโs easier for people to help you!
local Bullet = Instance.new("Part", workspace)
Bullet:SetAttribute("EnemiesPierced", 0)
Bullet:SetAttribute("TimesRicocheted", 0)
Bullet.CanCollide = false
Bullet.Massless = true
Bullet.Size = Properties.PartProperties.Size
Bullet.Color = Properties.PartProperties.Color
Bullet.Transparency = Properties.PartProperties.Transparency or 0
Bullet.Reflectance = Properties.PartProperties.Reflectance or 0
Bullet.Material = Properties.PartProperties.Material or Enum.Material.SmoothPlastic
if (game.Players.LocalPlayer.Character.Head.CFrame.Position - workspace.CurrentCamera.CFrame.Position).Magnitude < 1 then
Bullet.CFrame = ViewModel:WaitForChild("Item").Item.CFrame
else
Bullet.CFrame = game.Players.LocalPlayer.Character["Right Arm"].CFrame
end
game.Debris:AddItem(Bullet, 5)
local BulletVelocity = Instance.new("BodyVelocity", Bullet)
BulletVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
if (game.Players.LocalPlayer.Character.Head.CFrame.Position - workspace.CurrentCamera.CFrame.Position).Magnitude < 1 then
BulletVelocity.Velocity = workspace.CurrentCamera.CFrame.LookVector * Properties.MainProperties.Speed
else
BulletVelocity.Velocity = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector * Properties.MainProperties.Speed
end
local Touched = Bullet.Touched:Connect(function(Hit)
if Hit.Parent ~= ViewModel and Hit.Parent ~= game.Players.LocalPlayer.Character and Hit.Parent:FindFirstChild("Humanoid") then
DoDamage(Bullet, Hit, Properties)
if Bullet:GetAttribute("EnemiesPierced") > Properties.MainProperties.EnemiesToPierce then
Bullet:Destroy()
end
end
end)
spawn(function()
while task.wait() and Bullet do
if Bullet:GetAttribute("TimesRicocheted") <= Properties.MainProperties.RicochetTimes then
local HasRicocheted, RayInstance = require(script.Tools).Ricochet(Bullet, Properties, ViewModel)
Touched:Disconnect()
if HasRicocheted then
Bullet:SetAttribute("TimesRicocheted", Bullet:GetAttribute("TimesRicocheted") + 1)
end
if RayInstance and RayInstance.Parent:FindFirstChild("Humanoid") then
DoDamage(Bullet, RayInstance, Properties)
end
else
Bullet:Destroy()
break
end
end
end)