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

My Text Button Is Still Not Removing, How Come? What Could I Have Done Wrong?

Asked by
ImfaoXD 158
8 years ago

Its still doesn't work, I put it in the text button and still its doesn't work. what do I do wrong? What I'm trying to make the script do is to remove the text button with the word "Unlock" labeled in the text button from the image button when a player have 10 points or higher. I want the text button to remove, so the player can see the image button when they have 10 points or higher. I just want the text button to remove when a player reach the requirement points. Please check the link below to see what I'm talking about.

Also here is the screenshot to see what I'm talking about: http://prntscr.com/8la4ak

And also try out this game if you want to see how's the gui look like, even though I'm not making a pokemon game. I'm trying to make an rpg game that unlock characters when a player have 10 points or more. Here is the link:

http://www.roblox.com/games/30876086/Pokemon-Legends

Also here is the script that many people from script helpers have helped me and I'm really thankful for their helps!

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)

1 answer

Log in to vote
0
Answered by
DevArk 50
8 years ago

Your problem here is very simple but sometimes we think too hard and over see our simplest mistakes happens to the best of us ( and happens to me more than usual :P )

in your script on line 10 you should do ">=" not "==" because the player will earn more points correct? so that way your saying if the players points is more than or is 10 than you remove the GUI for them.

local player = game.Players.LocalPlayer
repeat wait() until player.Character -- So no errors occur later on ;)

local stats = player:WaitForChild('leaderstats')
local statsname = "Points"
local guiname = "ScreenGui"

stats[statsname].Changed:connect(function()
    print('Changed')
    if stats:FindFirstChild(statsname) then
        print('IT EXISTS!')
        if stats[statsname].Value >= 10 then -- If the value is more than or equals to 10 then do:
            print('VALUE EQUALS 10!')
            if player:WaitForChild('PlayerGui'):FindFirstChild(guiname) then
                print('found the gui')
                player.PlayerGui[guiname]:Destroy()
            end
        end
    end
end)

Hope this fixes it!

Ad

Answer this question