For one of my games I'm trying to make text appear then disappear after around 6/7 seconds The code doesn't seem to be working (probably because I don't have much coding knowledge)
Any ideas?
code:
01 | ` local Players = game:GetService( "Players" ) |
02 |
03 | Players.PlayerAdded:Connect( function (player) |
04 | player:LoadCharacter() |
05 |
06 | if Players.PlayerAdded then |
07 | script.Parent.TextLabel.TextTransparency = 1 |
08 | wait( 0.001 ) |
09 | script.Parent.TextLabel.TextTransparency = 0.9 |
10 | wait( 0.001 ) |
11 | script.Parent.TextLabel.TextTransparency = 0.8 |
12 | wait( 0.001 ) |
13 | script.Parent.TextLabel.TextTransparency = 0.7 |
14 | wait( 0.001 ) |
15 | script.Parent.TextLabel.TextTransparency = 0.6 |
What in the world is
1 | if Players.PlayerAdded then |
You don't have to have that line there, if you want to check if the player exists then do it like this:
1 | if player then |
Also instead of this big mess changing the transparency you should use for loops. So in your case:
1 | for transparency = 1 , 0 , - 0.1 do |
2 | script.Parent.TextLabel.TextTransparency = transparency |
3 | wait( 0.001 ) |
4 | end |
Also by using wait(0.001) i don't know if you modified the studio settings but if you haven't then the lowest value that can be put into wait is by default 0.03
so if i'm sure using 0.001 is same as using 0 or 0.02 or any number lower than the default.
You can put the code in a Localscript instead of a script
01 | wait( 5 ) --Replace the value with how long it takes to load into game |
02 | script.Parent.TextLabel.TextTransparency = 1 |
03 | wait( 0.001 ) |
04 | script.Parent.TextLabel.TextTransparency = 0.9 |
05 | wait( 0.001 ) |
06 | script.Parent.TextLabel.TextTransparency = 0.8 |
07 | wait( 0.001 ) |
08 | script.Parent.TextLabel.TextTransparency = 0.7 |
09 | wait( 0.001 ) |
10 | script.Parent.TextLabel.TextTransparency = 0.6 |
11 | wait( 0.001 ) |
12 | script.Parent.TextLabel.TextTransparency = 0.5 |
13 | wait( 0.001 ) |
14 | script.Parent.TextLabel.TextTransparency = 0.4 |
15 | wait( 0.001 ) |
I am too kind of new to scripting so I am not sure if this would work Maybe even make a variable for the textlabel