sup, i’m tryna modify this gun script to summon an explosion where the beam hits, but here’s the thing:
if i just set the explosion’s position exactly to the beam’s position, the explosion is in the middle, and i don’t want that, i want it at the end of the beam which is where the bullet is hitting
here’s the script, i do not take credit for it, it’s not mine by any means but i’m tryna modify it
castray.OnServerEvent:Connect(function(fired, ray, position)
local beam = Instance.new("Part")
beam.BrickColor = BrickColor.new("Institutional white")
beam.FormFactor = Enum.FormFactor.Custom
beam.Material = Enum.Material.Neon
beam.Transparency = .75
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
beam.Parent = workspace
local distance = (tool:WaitForChild("FirePart").CFrame.p - position).Magnitude
beam.Size = Vector3.new(0.1, 0.1, distance)
beam.CFrame = CFrame.new(tool:WaitForChild("FirePart").CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 0.025)
-- this is the part that i added in
local lol = Instance.new("Explosion",workspace)
lol.Position = Vector3.new(beam.Position.X,beam.Position.Y,beam.Position.Z) * beam.Size.Z
lol.BlastRadius = 5
lol.BlastPressure = math.huge
end)