So, I want to make a laser projector, currently i’m trying to figure out how to make figures like a circle, I do have a module that I made yesterday (yes its very bad I was lazy):
local BeamsFolder = script.Parent:WaitForChild("Beams")
local CasterPart = script.Parent:WaitForChild("Caster")
local SpotLight0 = CasterPart.SpotLight0
local Spotlight1 = CasterPart.SpotLight1
local Projector = {}
function Projector.newBeamToPoint(xStuds: number, yStuds: number, color: Color3, MaxDistance: number)
if xStuds and yStuds and color and MaxDistance then
local x2 = math.clamp(xStuds, -10, 10)
local y2 = math.clamp(yStuds, -10, 10)
local position = Vector3.new(0, 0, CasterPart.Position.Z)
local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {BeamsFolder}
local result = workspace:Raycast(CasterPart.Position, CasterPart.CFrame.LookVector * MaxDistance, raycastParams)
if result then position = Vector3.new(position.X, position.Y, result.Position.Z) else position = Vector3.new(position.X, position.Y, (CasterPart.CFrame.LookVector * MaxDistance)) end
if x2 < 0 then
position = Vector3.new((CasterPart.Position.X - -x2), position.Y, position.Z)
elseif x2 > 0 then
position = Vector3.new((CasterPart.Position.X + x2), position.Y, position.Z)
elseif x2 == 0 then
position = Vector3.new(CasterPart.Position.X, position.Y, position.Z)
end
if y2 < 0 then
position = Vector3.new(position.X, (CasterPart.Position.Y - -y2), position.Z)
elseif y2 > 0 then
position = Vector3.new(position.X, (CasterPart.Position.Y + y2), position.Z)
elseif y2 == 0 then
position = Vector3.new(position.X, CasterPart.Position.Y, position.Z)
end
SpotLight0.Color = color
Spotlight1.Color = color
SpotLight0.Enabled = true
Spotlight1.Enabled = true
print(position)
local result2 = workspace:Raycast(CasterPart.Position, position, raycastParams)
if result2 then
local midPoint = CasterPart.Position + position/2
local Beam = Instance.new("Part")
Beam.Material = Enum.Material.Neon
Beam.Anchored = true
Beam.CanCollide = false
Beam.Color = color
Beam.CanTouch = false
Beam.CFrame = CFrame.new(midPoint, CasterPart.Position)
Beam.Size = Vector3.new(.01, .01, position.Magnitude)
Beam.Parent = BeamsFolder
return Beam
end
end
end
function Projector.Clear()
BeamsFolder:ClearAllChildren()
end
return Projector
So that, uses numbers from -10 to 10 on the X and Y axis, and I want to make a circle with that. But how?
local random = Random.new(tick())
local projectorModule = require(workspace.LaserProjector.Projector)
local times = 0
while task.wait() do
times += 1
if times >= 50 then
projectorModule.Clear()
times = 0
end
projectorModule.newBeamToPoint(random:NextNumber(-10, 10), random:NextNumber(-10, 10), Color3.new(random:NextNumber(), random:NextNumber(), random:NextNumber()), 500)
end
^ that currently just puts beams in random positions:
and I want it to make patterns, like that circle I drew on the image. (I’m making a laser projector, tried to make reflecting rays at first but uhhh, yeah that wouldn’t work.)