I am trying to make a dots projector in my game. If you want a reference point try looking at the phasmophobia dots projector.
The Issue:
My code’s raycast system seems to not be working. Not only that I need a way to constantly update that raycast. For example, if something were to walk through the dots, then the dot/laser will be updated to that position of the raycast hit.
Note:
You will see a part that is generated in teal just to show me where the ray should be shooting as well as if the distance code is still working.
I also added a wait so it would go slower so I can see what it does. This can be changed.
Code:
local origin = script.Parent
local h, k, l = origin.Position.X, origin.Position.Z, origin.Position.Y
for i = 1, 360, 10 do
local x = h + 10 * math.cos(math.rad(i))
local z = k + 10 * math.sin(math.rad(i))
local y = l + 10 * math.sin(math.rad(i))
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(1, 1, 1)
part.Position = Vector3.new(x, origin.Position.Y, z)
part.Parent = workspace
part.BrickColor = BrickColor.new("Teal")
part.Transparency = 0.5
part.CanCollide = false
part.CanQuery = false
local Laser = Instance.new("Part")
Laser.Anchored = true
Laser.Size = Vector3.new(0.1, 0.1, 0.1)
Laser.Parent = workspace
Laser.BrickColor = BrickColor.new("Lime green")
Laser.Transparency = 0
Laser.CanCollide = false
Laser.CanQuery = false
local Result = workspace:Raycast(origin.Position, part.Position)
if Result then
Laser.Position = Result.Position
end
wait(0.3)
end
PLEASE HELP!!!