I have a script that looks like this:

local newThread = coroutine.create(function()
    while wait() do
        if game.Workspace.Part.Transparency == 1 then
        game.Workspace.Part.Transparency = 0
    end
end)
 
coroutine.resume(newThread)

-- there is more code down here, but it's not important for this question.

What I want to do is to change the while true do loop into a Changed function, but I'm not sure how I would put a function inside of a coroutine. Can anyone tell me how to do this?