Make spotlight follow the camera

Hi developers. I wanted to make a spotlight that follows players mouse. But i wanted to make it so only the rotation of the spotlight changes. How can i recreate this? I tried making it but failed. Also found something on devforum but broken

i found something that is exactly what im looking for (the flashlight):

Note: if something is unclear or i didn’t mention something - tell me. I am bad at explaining cuz im kinda not the best at english.

1 Like

You can do this by creating a part with your light in it setup, then in a local script control it by using cframe.new to set the position of the part then make it lookat a vector3 point

something like this

local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local RunService = game:GetService('RunService')

local LightPart = script.LightPart
LightPart.Parent = workspace

local Mouse = Player:GetMouse()
Mouse.TargetFilter = LightPart
RunService.RenderStepped:Connect(function()
	local Target = Mouse.Hit
	if Target then
		LightPart.CFrame = CFrame.new(Camera.CFrame.Position,Mouse.Hit.Position)
	end
end)

you may even add in beam etc for even more light effect

you can also use CFrame.lookAt

2 Likes

It worked! Thank you so much :DDD

1 Like

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