Invoked client script run a co-routine that could somehow return a value back to the caller

Hello all, have a wee issue here. It’s a little hard to explain but if my explanation doesn’t make sense then skip to the bottom for the main question :slight_smile:

In the game I’m creating when the player dies they aren’t actually killed yet. I just mark them as Dying with an attribute until they choose whether to revive or not. That’s all fine. But I’ve hit a snag.

I have a boss that if he catches you he challenges you with a math question. While you are being challenged you are frozen (i.e. Walk speed is zero). This is on purpose so that you are vulnerable to getting killed by other bosses. So when this boss catches you the server fires a Remote function (because it needs to wait until player has either answered incorrect or correct) for the player’s local GUI script to take over with the challenge. IF while you are being challenged, you get killed by a different boss, the challenge GUI stays there and also the local script doesn’t get the chance to return back a value.

My idea which seems rather messy is that the client when it gets fired, runs a co routine to constantly check if the player has been marked as Dying (Another boss, got the player). If it finds that to be true then stop the quiz and cleanup all the GUI stuff…The problem I have is that the co routine cannot return a value back to the original boss that called the Remote Function. So the boss will just sit there waiting for a reply :frowning:

The only solution I can think of is when the co routine does find the player Dying true, then cleanup the GUI’s and then destroy the original Boss and spawn another one in it’s place to carry on with his business.

Just wondering if there would be a better way.
Long story short…Can a remote function script run a co_routine that will return a value back to the originating script?

if you have some kind of script running when the attribute changes to dying could you not just clear the UI then or am I missing something.

Yep onChanged is another way but still have the same issue of getting a reply back to the server call.

As far as I know the only place that can return the value back to server is from within the function that was invoked

This catches the player getting caught by another boss but the return won’t work because its not returning those values back to the caller.

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
end

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