Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My Text Button Isn't Still Working Properly, Can Somebody Check What Could I Have Done Wrong?

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.

But please check this screen shot that i took, so you can see what i'm talking about:

http://prntscr.com/8lnoym

Also here is the script if you need to check:

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)

2 answers

✓ Accepted answer

I'm tired, and probably don't know what I'm reading or saying, but here goes:

local guiname = "ScreenGui"


--On line 16
player.PlayerGui[guiname]:Destroy()

The GUI name isn't ScreenGui.

I believe you are making a new value for "Points". In this case add this after line 4

Points = Instance.new('IntValue')
Points.Parent = stats
Points.Name = "Points" --you can use ' or " just so you know

Points.Changed:connect(function()
  print('Changed')
     if stats:FindFirstChild(statsname) then
	if stats[statsname].Value >= 10 then
            if player:WaitForChild('PlayerGui'):FindFirstChild(guiname) then
                player.PlayerGui[guiname]:Destroy()
            end
        end
    end
end)

1 comment

0

You could however add already the IntValue named "Points" in the leaderboard so that you won't have to be pressured on a long line of code here. Hope this helps :)

This discussion is preserved as it was. New answers, comments, and votes are closed.