What I'm trying to make the script do is to remove the text button from the image button when a player have 10 points or higher. But the text button is in the image button. I just want the text button to remove when a player have 10 point or higher. Can you guys help me?
Here is the script that someone have helped me:
01 | wait( 1 ) |
02 | local player = game.Players.LocalPlayer |
03 | local stats = player:WaitForChild( "leaderstats" ) |
04 | local statname = "Points" |
05 | local guiname = "ScreenGui" |
06 |
07 | stats:WaitForChild(statname).Changed:connect( function () |
08 | if stats:FindFirstChild(statname) then |
09 | if stats:FindFirstChild(statname).Value = = 10 then |
10 | if player:WaitForChild( "PlayerGui" ):FindFirstChild(guiname) then |
11 | player.PlayerGui:FindFirstChild(guiname):Destroy() |
12 | end |
13 | end |
14 | end |
15 | end ) |
Thank You For Your Time!
Check if the names match what you have. statname and guiname. Are there multiple ScreenGuis with the name "ScreenGui"?
1 | -- You can also do this: |
2 |
3 |
4 | stats:WaitForChild(statname).Changed:connect( function (val) |
5 | if val = = 10 then |
6 | -- your code here, you won't need the FindFirstChild checking lines you had before |
7 | end |
8 | end ) |
Either way, I tested this and It worked:
01 | local player = game.Players.LocalPlayer |
02 | local stats = player:WaitForChild( "leaderstats" ) |
03 | local statname = "Points" |
04 | local guiname = "ScreenGui" |
05 |
06 | stats:WaitForChild(statname).Changed:connect( function () |
07 | print ( "Changed" ) |
08 | if stats:FindFirstChild(statname) then |
09 | print ( "IT EXISTS!" ) |
10 | if stats:FindFirstChild(statname).Value = = 10 then |
11 | print ( "VALUE EQUALS 10!" ) |
12 | if player:WaitForChild( "PlayerGui" ):FindFirstChild(guiname) then |
13 | print ( "found the gui" ) |
14 | player.PlayerGui:FindFirstChild(guiname):Destroy() |
15 | end |
16 | end |
17 | end |
18 | end ) |
Screenshots: http://prntscr.com/8l2lel http://prntscr.com/8l2ls3
I saw your other post,
You won't be able to just copy and paste the script in, you'll need to change a few of the variables.