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

I added this script to my TextButton... should it work?

Should this work. If you have the game pass then this should work. THis script is inserted in a TextButton.

local passId = 182358984
 
function isAuthenticated(player)
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end
 
game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        print("Loaded gamePass for a Player")
	 script.Parent.MouseButton1Click:connect(function()
	    number = 0
	    number = number + 3
	    script.Parent.Parent.TextBox.Text = number
	else
	    number = 0
	    number = number + 1	    
		script.Parent.Parent.TextBox.Text = number
		end)
	end
end)

3 comments

0

I got most of this from the ROBLOX wiki.

0

Um... in Studio there is an error on line #14.

0

I think that since "else" is in a function it does not work but I don't know any onther way to do this...

1 answer

local passId = 182358984

function isAuthenticated(player)
	return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
	local number = 0
	if isAuthenticated(plr) then
		print("Loaded gamePass for a Player")
		script.Parent.MouseButton1Click:connect(function()
			number = number + 3
			script.Parent.Parent.TextBox.Text = number
		end) -- Moved the end here
	else
		number = number + 1     
		script.Parent.Parent.TextBox.Text = number
	end
end)

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