So I got this annoying problem I've been trying to solve for more than an hour now.
Here's the code:
script:WaitForChild("DetectLevels").Event:connect(function() local IsInLight = false local function CheckForLight(Player) print(tostring(Player)) --Firstly prints my name and then prints "nil" a second time for i, l in pairs(game.Workspace:WaitForChild("Lights"):GetChildren()) do local distance = math.floor((game.Workspace:FindFirstChild( tostring(Player) ) .HumanoidRootPart.Position - l.Position).magnitude) if distance <= l:WaitForChild("Range").Value then --IsInLight = true return true end wait(.1) end end while wait(1) do for i, v in pairs(game:GetService("Players"):GetChildren()) do if game.Workspace:FindFirstChild(tostring(v)) then CheckForLight(tostring(v)) print(tostring(v).." is in light: "..CheckForLight()) wait(.1) end end wait(10) end end)
I'd really really appreciate any sort of help!
Just found the issue.
The problem was with the print, doing: print( MyFunction() ) won't show the return value and just be nil, I'll be trying to solve that problem rn