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

How do I destroy a button on the player GUI?

Hi all, I have a skip stage button on my player GUI, however I want to remove it once the player reaches the last level. Annoyingly, it allows you to use it after level 40 which then just sends you to the initial spawn point and puts your level at 41+ etc. so I don't want them to be able to use it and get nothing in return.

This is the particular part that raises the level each time it is used:

MarketplaceService = Game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
	players = game.Players:GetPlayers()
	
	currency = "Stage"
	
	done = 0
	
	for i=1,#players do
		if players[i].userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == 1083806372 and done == 0 then
				done = 1
				players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
				players[i].Character.Humanoid.Health = 0
				done = 0
			end
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted	
end

Any help would be appreciated, thanks

1 answer

Try to add

local

before your variables

local currency = "stage"

roblox thinks currency is a function or a not newl typed variable. and closes script

2 comments

0

Actually, you don't need to use local. People only use local when inside functions or events. But yes, using local IS recommended.

0

Thanks have done that, how can I remove the button from the Gui though. I want it to disappear when they reach stage 40? Thanks

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