Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ran into bug making a detect part ray?

Asked by 6 years ago

So im trying to make a script that uses a ray to detect a part, and then makes that part a frame, but i ran into a bug, any help?


local Board = game.Workspace.Board while wait(0) do local ray = Ray.new(script.Parent.CFrame.p, (script.Parent.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, script.Parent, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("Bright red") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0.25 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (script.Parent.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3, 0.3, distance) beam.CFrame = CFrame.new(script.Parent.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local newFrame = Instance.new("Frame",game.Workspace.Board.SurfaceGui) newFrame.Size.X = part.Size.X newFrame.Size.Y = part.Size.Y newFrame.BorderSizePixel = 0 newFrame.BackgroundColor3 = Color3.fromRGB(part.Color) end end
0
1) Read my bio. 2) What bug? hiimgoodpack 2009 — 6y

Answer this question