Say I wanted to add a "shield" to be depleted before health when a player takes damage, and said shield would regenerate on its own if no damage is taken in 10 seconds. How could I setup a function that waits a certain duration and returns true if the duration expires?
I read somewhere about using :wait() in this way but I have no idea how to have it return values.
function waitForChange(element, duration)
repeat until element.Changed:wait(duration) --Return false if event fires before duration
-- Return true if nothing fires
end
Sorry if the answer is actually really obvious, I'm very much a beginner at this.

2 comments
just realized I wrote this incorrectly but this should work for you anyways
I can kind of see where you're going with that. I probably should've given you more info on how I'm handling shield (that's my bad) but I can use your script as a guideline. Thanks a bunch!