Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Nope, Its Doesn't Work, Can Somebody Help me?

Asked by
ImfaoXD 158
8 years ago

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:

wait(1)
local player = game.Players.LocalPlayer 
local stats = player:WaitForChild("leaderstats") 
local statname = "Points" 
local guiname = "ScreenGui" 

stats:WaitForChild(statname).Changed:connect(function()
    if stats:FindFirstChild(statname) then 
        if stats:FindFirstChild(statname).Value == 10 then 
            if player:WaitForChild("PlayerGui"):FindFirstChild(guiname) then 
                player.PlayerGui:FindFirstChild(guiname):Destroy() 
            end
        end
    end
end)

Thank You For Your Time!

0
Is this in a LocalScript, like it's supposed to be? ISellCows 2 — 8y
0
Yes, But It's Doesn't Work. ImfaoXD 158 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Check if the names match what you have. statname and guiname. Are there multiple ScreenGuis with the name "ScreenGui"?

-- You can also do this:


stats:WaitForChild(statname).Changed:connect(function(val)
    if val == 10 then
        -- your code here, you won't need the FindFirstChild checking lines you had before
    end
end)

Either way, I tested this and It worked:

local player   = game.Players.LocalPlayer 
local stats    =  player:WaitForChild("leaderstats") 
local statname = "Points" 
local guiname  = "ScreenGui" 

stats:WaitForChild(statname).Changed:connect(function()
    print("Changed")
    if stats:FindFirstChild(statname) then 
        print("IT EXISTS!")
        if stats:FindFirstChild(statname).Value == 10 then 
            print("VALUE EQUALS 10!")
            if player:WaitForChild("PlayerGui"):FindFirstChild(guiname) then 
                print("found the gui")
                player.PlayerGui:FindFirstChild(guiname):Destroy() 
            end
        end
    end
end)

Screenshots: http://prntscr.com/8l2lel http://prntscr.com/8l2ls3

Ad
Log in to vote
0
Answered by 8 years ago

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.

Answer this question