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

My Text Button Isn't Still Working Properly, Can Somebody Check 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.

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

Log in to vote
0
Answered by 8 years ago

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.

Ad
Log in to vote
0
Answered by 8 years ago

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)

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 :) hardhitsniper 30 — 8y

Answer this question