local killed = coroutine.create(function()
		print("Killed coroutine called")
		if script:FindFirstChild("Killed").Value == true then
			print("ending game")
			endgame("dead")
		end
	end)
	local timer = coroutine.create(function()
		for i = 0, 60, 1 do
			wait(1)
		end
		endgame("time")
	end)
	coroutine.resume(timer)
	script:FindFirstChild("Killed").Changed:connect(function()
		if script:FindFirstChild("Killed").Value == true then
			coroutine.resume(killed)
		end
	end)
end

function endgame(status)
	coroutine.yield(killed)
	coroutine.yield(timer)

This is a small portion of the script, don't worry too much about the ends.

Basically the script is supposed to listen for the variable "Killed" to turn true or until the time runs out, then it stops the other coroutine and carries on with the rest of the script.

What is wrong?

1 comment

0

Is the 'Killed' thing a child of the script, or are you trying to find the 'killed' variable in the script's code? If you are trying to find the 'killed' variable in code of the script, you can just write 'killed'