Flashlight attached to camera

(Bruh i forgot to change from unsolved to solved :confused: )

Hi, i am trying to make a flashlight with a Spotlight, that would follow players camera and be there everytime. But i have no idea how to. I tried parenting it to player’s head but i would need to make player head movement - which i did but it looked laggy. I would be happy for every response about it.

Instead of parenting it to the player’s head maybe you could try parenting it to the player’s camera? If this doesn’t work, you can do this:

local camera = game.Workspace.CurrentCamera--note that this only works in local which could be a problem of not
local FlashLight = game.Workspace.?--remember to assign this to your flashlight no need to make multiple since the movement will be local

while true do
    FlashLight.Position = camera.Position--this makes the flash light position the same as the camera position
    FlashLight.Orientation = camera.Orientation
    task.wait(.05)
end

This is a simple script but should work, thanks for reading

1 Like

you can also use FlashLight.CFrame = camera.CFrame

2 Likes

Well, they don’t really work. There is no property in cera called Position or Orientation. And changing it’s CFrame doesn’t work too. Or im just doing it wrong. It may be confusing, but i want to do the GMOD flashlight effect. The one after clicking F i think. Is it possible?

Also, this only glitches in first person, so i have no idea what is causing this

There is cameras CFrame.Position only so my bad. Maybe that is what you thought.

It seems like there is a second part. That is non transparent and collisions are off.

It worked. I had to mess with the scripts. Also. The flashlight part was welded and a Wall was glitching my camera collision :stuck_out_tongue:

You can simply set the flashlight’s CFrame (assuming it’s a part), to the camera’s CFrame.
Basically do this:

FlashLight.CFrame = camera.CFrame

1 Like

Ye, i know, i forgot to change title bcs i arleady got help

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