How would i create a beam to screen gui

Hello im trying to create a beam between a part instance in workspace and a ui element in Screen Gui / Player Gui, like in this image.

What i’ve tryed is:

local beam =  Instance.new("Beam", workspace)
local attach1, attach2 = Instance.new("Attachment", workspace.BeamPart), Instance.new("Attachment", script.Parent)

beam.Attachment0 = attach1
beam.Attachment1 = attach1

beam.Enabled = true

But i get following error: Attachments must be parented to a PartInstance.
Any help appreciated

3 Likes

(Just a guess)
But couldnt you do a constantly changing ray casting to the current camera cframe but slightly tweaked

1 Like

I honestly doubt the image you’re showing is actually using a beam, BUT, if you do want to make a beam attach to a gui, I don’t think you can do it with screengui but you can do it with a billboard/surfacegui parented and adorned to a part

what other techique is that image using?

The technique the image is using MIGHT be what I said, but don’t quote me on that because there’s honestly no way for me to know since I’m not the developer of that game.

It might also just be using pre-rendered textures

Take a look at Camera:WorldToViewportPoint

2 Likes

Okay so i made it working with Camera:ScreenPointToRay. Thanks for yall help :smiley:

5 Likes

hey there! can you show an example of the code? im trying to create a similar thing but apparently im too dumb to do this. thanks!

2 Likes