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!
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.