local camera = Workspace.CurrentCamera local player = game.Players.LocalPlayer repeat wait() until player.Character local char = player.Character while true do dist = (camera.CoordinateFrame.lookVector - game.Lighting:GetSunDirection()).magnitude if dist < 0.1 then print(player.Name .. " looked at sun.") end wait() end
I recommend adding an "else print(dist)" after line 7 (and then changing line 9 to be "wait(1)" so that your output window doesn't flood too quickly). If nothing prints out, there's a problem with lines 1-3 (I would suspect that you might be accessing the camera before it exists, for instance. If that's the case, move line 1 to after the 'repeat' loop.). Otherwise, the print statements will print out and perhaps you'll find that "dist < 0.1" is too small a range (though when I tested it, I was able to get below 0.1).
Instead of a while loop, consider using the .Changed event, which will only fire when the player moves their camera. Use it like this:
local player = game.Players.LocalPlayer repeat wait() until player.Character local char = player.Character local camera = workspace.CurrentCamera camera.Changed:connect(function() dist = (camera.CoordinateFrame.lookVector - game.Lighting:GetSunDirection()).magnitude if dist < 0.1 then print(player.Name .. " looked at sun.") end end)