Function returning nil even though the print shows a value

image

image
as u can see

1 Like

image

1 Like

It’s because you’re returning the embedded function and not the local function. You can do this as a workaround:

--Don't feel like copying the whole script, here's a general idea
local function ResearchChecks(science)
local referencevalue

RepStorage.Remotes.TechEvent.OnClientEvent:Connect(function(val)
print (val)
referencevalue = val
end)
while task.wait() do
if referencevalue ~= nil then 
return referencevalue
end
end

Sorry for poor formatting

1 Like

worked, thanks i spent too long on this lol

2 Likes

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