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

How would I attach an object to camera?

Asked by
Exsius 162
10 years ago

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?

0
There isn't a supported way, you'll be manually positioning the part :D Bubby4j 231 — 10y
0
alright thanks! Exsius 162 — 10y

1 answer

Log in to vote
2
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago
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.

Ad

Answer this question