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

My Text Button Isn't Removing?

Asked by
ImfaoXD 158
8 years ago

I'm trying to make this script remove the text button when the player have collected 10 coin or more, but it doesn't work. Did I put it in the wrong script? What did I do wrong? Can you guys help me?

You can look at this screen shot if you would like to see: http://prntscr.com/8lnoym

If you want the model, I can give it to you. So you could have a better of understanding:

http://www.roblox.com/My/Item.aspx?ID=311894614

local player = game.Players.LocalPlayer
repeat wait() until player.Character 

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

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

Many thanks, my friends!

1 answer

Log in to vote
0
Answered by
Im_Kritz 334 Moderation Voter
8 years ago

Hey bud, I'll help you out

First of all, you don't need to state the statsname in a variable. So you can get rid of these two:

local statsname = "Points"
local guiname = "Unlock"

Secondly, I removed all the prints for now to save me some time and eye sore. I removed the stats.Points because we already know the script checked for that. I check for the stats and end it on the same line to save some space.

local player = game.Players.LocalPlayer
local stats = player:WaitForChild('leaderstats')

stats:WaitForChild('Coins').Changed:connect(function()
    if stats.Coins.Value >= 10 then
        script.Parent:Destroy()
    end
end)

if stats.Coins.Value >= 10 then script.Parent:Destroy() end

I can always edit this if it doesn't work, so give me some feedback.

Update: I took your model and tested. You had no "Points" there were "Coins", I tested my code it worked, I did was changed the Points to Coins.

Update II: I added an extra line in there in case you die or reset the Unlock Blackout with be gone.

0
I tested it and it doesn't work. Can you check if I made some error mistakes? ImfaoXD 158 — 8y
0
I updated the model so you can check it. ImfaoXD 158 — 8y
0
I updated my code, I explained what the problem was on the update Im_Kritz 334 — 8y
0
Thank you, my friend! 1 Point for you!!! :) ImfaoXD 158 — 8y
View all comments (7 more)
0
But there's is still one problem. When I reset, the text button come back. So I have to collect all the coins again for it to remove. Is there a way to make it remove permitted without having to collect it again when I reset? ImfaoXD 158 — 8y
0
I updated the model again, so you can check it. ImfaoXD 158 — 8y
0
I updated my code again, and you're welcome man Im_Kritz 334 — 8y
0
Ummm, can you help me again? I don't know how to explain this but I make a team selection for my sonic GUI and my text button isn't removing when I collected the coins. Again, I'm sorry to bothered you again. Can you help me? Please. D: ImfaoXD 158 — 8y
0
I updated the model again, so you can check it out. ImfaoXD 158 — 8y
0
Here is the link to the model: http://www.roblox.com/unnamed-item?id=313163376 ImfaoXD 158 — 8y
0
Please, if you're online. :( ImfaoXD 158 — 8y
Ad

Answer this question