for some reason only some lines of code work. for example, i want to add locational damage for when someone gets hit in the head or limbs but all it does it default to the amount of damage set, i also wanted to add a ricocheting option for the bullets but that code didn’t run either, i’m not sure if i’m just missing something or my code is so bad that it doesnt work. also print statements dont work and errors arent given
local Bullet = Instance.new("Part", workspace)
Bullet.Size = Properties.PartProperties.Size
Bullet.Color = Properties.PartProperties.Color
print("Yes")
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.Item.Item.CFrame
else
Bullet.CFrame = game.Players.LocalPlayer.Character["Right Arm"].CFrame
end
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
Bullet.Touched:Connect(function(hit)
if hit.Parent ~= ViewModel and hit.Parent ~= game.Players.LocalPlayer.Character and hit.Parent:FindFirstChild("Humanoid") then
if Properties.MainProperties.LocationalDamage == true then
if hit.Name == "Head" then
DamageEvent:FireServer(hit.Parent, Properties.MainProperties.Damage * 2)
elseif string.find(hit.Name, "Arm") or string.find(hit.Name, "Leg") then
DamageEvent:FireServer(hit.Parent, Properties.MainProperties.Damage * 1.5)
else
print("Ues")
DamageEvent:FireServer(hit.Parent, Properties.MainProperties.Damage)
end
else
print("Ues")
DamageEvent:FireServer(hit.Parent, Properties.MainProperties.Damage)
end
if not hit.Parent.Humanoid:HasTag("Pierced") then
hit.Parent.Humanoid:AddTag("Pierced")
EnemiesPierced += 1
wait(1)
game.CollectionService:RemoveTag(hit.Parent.Humanoid, "Pierced")
end
if EnemiesPierced == Properties.MainProperties.EnemiesToPierce then
Bullet:Destroy()
end
end
end)