One method you could use is constantly calculating the distance between the player and that part. You can do this by using the Player:DistanceFromCharacter method which returns the distance between the player's head and the given position. You should use the part's position as the argument.
Essentially, you can set the transparency of the GUI to be the percentage distance the player is from a set max distance. Let me explain:
Say you want the GUI to start visibly fading in at a distance of 10 units away. We will call this value MAX_DISTANCE. We can constantly calculate the distance between the player and the part using the method above, and name this value CURRENT_DISTANCE. The transparency of the GUI will depend on how far away the player is compared to MAX_DISTANCE.
For example, let's say the player is currently 5 units away from the part. The transparency of the part would be CURRENT_DISTANCE / MAX_DISTANCE which is 0.5. When the player comes very close to the part (CURRENT_DISTANCE approaches 0), the transparency also approaches 0 (0 / any number = 0). If CURRENT_DISTANCE >= MAX_DISTANCE, then we can simply set the transparency to 1.
With this system, the player will have a dynamic fading GUI that will become more opaque as he approaches the part, and more transparent as he walks away, with max transparency being at your specified MAX_DISTANCE.
Hope this helps! :)
2 comments
I did al ittle correction and it worked THank you so much !
No problem! Happy to help.