How to attach beam from a part to a torso if you clicked the part?

Well, i just really don’t know how to do that. Would be helpful if you show me example of script or send me some useful articles. Thanks

1 Like

It’s honestly pretty simple. All you would have to do is detect when a click detector is clicked, attach the beam’s Attachment0 to an attachment in the part, and attach the beam’s Attachment1 to the player’s character’s HumanoidRootPart.RootAttachment.

1 Like

pretty stupid question but, can i put beam inside the button?

1 Like

The beam itself can be anywhere, but the attachment needs to be inside of a part

1 Like

Here’s the Roblox documentation to explain them.
Beam | Documentation - Roblox Creator Hub
Beams | Documentation - Roblox Creator Hub

To find out where the mouse is clicking do you mean on a Part that will only have the beam connected to it (like @juhggsfdhfdhhfd55 said, with a ClickDetector), or do you mean to whatever the mouse is pointing at in the game (using a Raycast from the player to the actual spot clicked using the mouse in the game)?

Sorry but, could you explain me it in detail. Rlly sorry, my brain just cant understand. Thanks.

i mean that if you click a part, beam will appear from the part to your torso

Basically, you parent the beam anywhere inside of the workspace. Then, you want to add an attachment inside of the first part and make the Attachment0 property of the beam equal to that attachment. Then, you want to add another attachment to your second part, and set the Attachment1 property of the beam to that attachment. In your case, the Attachment1 is the plr’s humanoidRootPart attachment.

Here is a code snippet if you still don’t get what I’m saying.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	script.Parent.Beam.Attachment0 = script.Parent.Attachment
	script.Parent.Beam.Attachment1 = plr.Character.HumanoidRootPart.RootAttachment
end)
2 Likes

Thanks for explaining!
Have a nice day.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.