Apologies for a new question. I made the original question waaaay more complex than it needed to be,. All I want to know is, can I return a value from outside of an invoked function back to the caller?
For example in the below code I can’t return the value back from within the changedsignal function. Is there a way I can?
questionsEvent.OnClientInvoke = function(player)
character:GetAttributeChangedSignal("IsDying"):Connect(function()
print("Debug: Player got smacked while being tested")
return true, 10 -- *This won't work because it returning it nowhere*
end)
-- Boss performing his tests from here on in
-- and successfully returning values back to caller
end
But if you want the server to do something when a character is dying, you should call the server from that event, not have a RemoteFunction constantly on hold.
If you REALLY want to do the bad practice of keeping a remotefunction on hold you should do it like this:
questionsEvent.OnClientInvoke = function(player)
if character:GetAttribute("IsDying") then return true, 10 end
character:GetAttributeChangedSignal("IsDying"):Wait()
return true, 10
end
But this is so bad, I wouldn’t touch your code with a 10ft pole after this.
Yep I figured if there wasn’t a way to return from within the change trigger that I would just create a new event to fire back at the server. So I’ll go with option 2.