function destroyMessage() wait(5) while true do script.Parent.Frame.BackgroundTransparency = script.Parent.Frame.BackgroundTransparency + 0.05 script.Parent.TextLabel.TextTransparency = script.Parent.TextLabel.TextTransparency + 0.05 wait(0.1) end
end
destroyMessage()
This might help you. I've been lately seeing that (Don't quote me. I'm sometimes wrong) that wait()
isn't as good as using a yield or things to that effect. (Could still be wrong)
function destroyMessage() wait(5) while true do script.Parent.Frame.BackgroundTransparency = script.Parent.Frame.BackgroundTransparency + 0.05 script.Parent.TextLabel.TextTransparency = script.Parent.TextLabel.TextTransparency + 0.05 wait(0.1) end end destroyMessage()
That is your original code. I dislike it for a variety of reasons. Firstly, it's not recommended to keep a loop within a function. Secondly, this code is terrible (sorry I had to). It won't do what your looking for. It will run infinitely. Do you know at what point you want the transparency to go to? Assuming you want it at 1, you can easily achieve this with something like:
function destroyMessage() while script.Parent.Frame.BackgroundTransparency ~= 1 do script.Parent.Frame.BackgroundTransparency = script.Parent.Frame.BackgroundTransparency + 0.05 script.Parent.TextLabel.TextTransparency = script.Parent.TextLabel.TextTransparency + 0.05 wait(0.1) end destroyMessage() end
A disclaimer. I've put waits in here, as its good enough for this. You can get nitty gritty and use different methods of making your script wait, but for most cases using wait()
is perfectly ok.
Now onto what I've done to your code. Firstly, I removed the 5 second delay from the function start. It made no sense to put there. Secondly, I added a conditional statement to make your loop end. I still don't like it, but its good enough and keeps what you wanted to achieve in mind. The next part I added was moving the destroyMessage() function up into the function. Leaving it outside of it doesn't do anything, and it will now run once the loop is over.
Hope it helps!
You put wait(5) which is going to have the script wait 5 seconds before it does the while true do loop. lower the wait time and that should work