I'm trying to make a script keep checking a part's transparency frequently.. The part's default transparency is zero, and another script is coded to change the transparency to 1. The main script is supposed to constantly check what the transparency is, and once it finds out the transparency is 1, it'll stop checking. How do I do this? (Just so you know, the transparency checker script is a local script)
I try writing this:
if workspace.Part.Transparency == 1 then --enter action here end
It obviously doesn't work because the script runs when the player spawns, and it only checks once.
You can spawn a function that uses a while loop to check. In my opinion it's better to spawn a function instead of using a while loop because you can keep using the rest of the script even while the loop is running.
Then use a .Changed event to check to see each time if the transparency has changed.
local x = 1 -- So you can break the function whenever you want, just set x to another value. spawn(function() workspace.Smoke.Changed:Connect(function() while x == 1 do wait() if workspace.Smoke.Transparency == 1 then workspace.Smoke.Transparency = 0 else return end end end) end)