How do you make a spotlight follow a players mouse

Someone asked me how to make a spotlight follow a players mouse and I did not know how to. Can someone tell me how to make a spotlight follow a players mouse

2 Likes

local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(1,1,1)
part.Transparency = 1
part.Parent = game.Workspace
local SpotLight = Instance.new("SpotLight",part)
SpotLight.Brightness = 1000
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
mouse.Move:Connect(function()
	part.CFrame = mouse.Hit

end)

If you do not want the SpotLight to clip through walls, you could also use Raycasting to cast a ray to the player’s mouse position.