Hi, I wanna make a shotgun. But I don’t know how so, I have an existing code that I’d like to turn it in a shotgun, here’s the code:
**BeamEvent.OnServerEvent:Connect(function(Player, laserpos, target)
local ray = Ray.new(laserpos, (target - laserpos).Unit*250)
local hit, position = game.Workspace:FindPartOnRay(ray, nil)
pcall(function()
local HumanoidToDamage = hit.Parent:FindFirstChild("Humanoid")
if HumanoidToDamage and HumanoidToDamage ~= Player.Character.Humanoid then
HumanoidToDamage:TakeDamage(20)
print(HumanoidToDamage.Parent.Name .. " just got hit by beam. ")
end
local Beam = Instance.new("Part", game.Workspace)
Beam.Name = "Beam"
local dist = (target - laserpos).magnitude
Beam.Size = Vector3.new(0.3,0.3, dist)
Beam.CFrame = CFrame.new(laserpos, position) * CFrame.new(0,0,-dist/2)
Beam.Anchored = true
Beam.CanCollide = false
Beam.BrickColor = BrickColor.new("Really red")
Beam.Material = Enum.Material.Neon
debris:AddItem(Beam, 0.01)
end)
end)
Thanks all!