Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Coroutine not accepting player as a parameter?

I was testing my code, and for some reason, my coroutine can't obtain a player as a parameter. This is the part of my script:

local rotCor = coroutine.create(self.setRotation)
print("Sending:",targetPlayer)
coroutine.resume(rotCor,targetPlayer)

function Properties:setRotation(targetPlayer)
	print("Received:",targetPlayer)
	--Blah blah blah
end

When I execute my code, this is the output:

Sending: SnyFort

Received: nil

Is It a normal behavior of a coroutine? This code is within a Module script executed in a LocalScript.

I'm using coroutines because I don't want the function to interrupt the rest of the code, so if you know any alternative, I'd like to try It.

Thanks.

1 answer

Nevermind...The solution was pretty simple lol

function Properties:setRotation(targetPlayer)
	local executeCor = coroutine.wrap(function()
		print("Received:",targetPlayer)
	end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.