Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I attach an object to camera?

Like making parts that are attached to players camera.

I have done it once in unity but the unity engine is different from roblox's

Any tutorials on this I can find?

2 comments

0

There isn't a supported way, you'll be manually positioning the part :D

0

alright thanks!

1 answer

local camera=workspace.CurrentCamera
local part=Instance.new("Part",camera) -- local parts
part.FormFactor="Symmetric"
part.Size=Vector3.new(1,1,1)
part.Anchored=true
part.CanCollide=false

camera.Changed:connect(function()
	part.CFrame=camera.CFrame*CFrame.new(0,0,10)
end)

This makes a 1x1x1 part stay 10 studs directly in front of your camera whenever your camera changes. Assuming the camera does fire the changed event whenever your character moves because the camera follows your character, this will work.

This discussion is preserved as it was. New answers, comments, and votes are closed.