I want to make 5 beams in a line in a 45 degree cone from where the endpart is located, how do i do so?

Kinda like in this pic, bottom is the Tip top is how i want beams to go, middle one is hit position and the other 4 offset from it: https://gyazo.com/3a6f95ac903dff86eb3690f8a3c82777

WidebeamStunFire.OnServerEvent:connect (function(player, mousehit, Tool, tip, char)
	if Tool.CurrentCharge.Value >= 50 then
	Tool.CurrentCharge.Value = Tool.CurrentCharge.Value - 50
	local ray = Ray.new(tip.CFrame.p, (mousehit - tip.CFrame.p).unit * 100)
	local impact, position = workspace:FindPartOnRayWithIgnoreList(ray, ignorelist, false, true)
	print ("Beam Creation")
	local beam = Instance.new("Part", workspace)
		beam.BrickColor = BrickColor.new("Steel blue")
		beam.Material = "Neon"
		beam.Transparency = 0.95
		beam.Anchored = true
		beam.Locked = true
		beam.CanCollide = false
		local StunBeamFX = Tool.Handle.StunBeamFX:Clone()
		StunBeamFX.Parent = beam
		StunBeamFX.Enabled = true
		Tool.Handle.shot:Play()
		game:GetService("Debris"):AddItem(beam, 0.15)
		local distance = (tip.CFrame.p - position).magnitude
		beam.Size = Vector3.new(0.1, distance, 0.1)
		beam.CFrame = CFrame.new(tip.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) * CFrame.Angles(math.rad(90),0,0)
		if impact then
			local humanoid = impact.Parent:FindFirstChild("Humanoid")
			if not humanoid then
				   humanoid = impact.Parent.Parent:FindFirstChild("Humanoid")
			end
 		if humanoid then
				math.randomseed(tick())
				local d = math.random(5,10)
				humanoid:TakeDamage(d)
				humanoid.Sit = true
				print(d)
else
				if (impact.Parent:FindFirstChild("VehicleHealth")) and (not impact.Parent:FindFirstChild("GateshipShield")) then
					impact.Parent.VehicleHealth.Value = impact.Parent.VehicleHealth.Value - VehicleDamageStun
				end
				if (impact.Parent:FindFirstChild("ShieldHealth")) and (impact.Parent:FindFirstChild("GateshipShield")) then
					impact.Parent.ShieldHealth.Value = impact.Parent.ShieldHealth.Value - ShieldDamageStun
					print("energydmgstun")
				end
        		local prt = Instance.new("Part")
				prt.Transparency = 1
				prt.Anchored = true
				prt.Size = Vector3.new(0.2,0.2,0.2)
				prt.Parent = game.Workspace
				prt.Position = position
				local StunFireFX = Tool.Handle.StunFireFX:clone()
				StunFireFX.Parent = prt
				StunFireFX.Enabled = true
				local StunShotLight = Tool.Handle.StunShotLight:clone()
				StunShotLight.Parent = prt
				StunShotLight.Enabled = true
				wait(0.5)
				prt:Destroy()
			end
		end
	end
	wait(0.5)
end)

1 comment

0

try using a for loop to create multiple parts and offset the parts