How to update values given to a coroutine wrap?

I am trying to use a coroutine wrap to update things with multiple players at once, the only problem I’m having is that for some reason when I go to pass the new players value through it it doesn’t update it and thinks it’s still the original value. how would I go about doing this?

function called with arguments below

civiselect(v)

full function detail below

civiselect = coroutine.wrap(function(civi)
	while true do
	local rs = game.ServerStorage.RoleSelect:Clone()
	rs.Parent = civi.PlayerGui
	rs.TextLabel.Text = "You are a civilian"
	print(civi.Name)
	rs.TextLabel.BackgroundColor3 = Color3.fromRGB(0,170,0)
	coroutine.yield()
	end
end)

I don’t really think you want to use a coroutine for this, but it’s hard to know exactly what you’re trying to do. Your code doesn’t block, so I think you just want a normal function.

Anyways, coroutine wrap works like this.

The first call sets the parameter.

Subsequent calls set the return value of the coroutine.yield()

A simpler example:

local f = coroutine.wrap(function(x)
  while true do
    print("x =", x)
    print("yield() =", coroutine.yield())
  end
end)

f(1)
-- x = 1

f(2)
-- yield() = 2
-- x = 1

f(3)
-- yield() = 3
-- x = 1

I was using a coroutine as I was trying to add a wait function without blocking the rest of the script. I eventually just created a temporary value which I moved over to the function and that seems to have done the trick.