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

Gamepass Gui not showing up?

No error I think it has to do with something on the PlayerGui line...

gps = game:GetService("GamePassService");
id = 166087748 
VIP = {"Player1"} 
players = game.Players:GetPlayers()

for i=1,#VIP do
	for i=1,#players do
		if players[i].Name == VIP[i].Name or gps:PlayerHasPass(players[i], id) then
			players[i].PlayerGui.Gui.TextButton.Visible = true
		else return end
		end
	end




1 answer

You're using the variable i in both for loops, so the if statement would error because you're essentially replacing the first i variable in the first for loop with the second for loop, meaning both variables would conflict with each other.

The way to fix this is to use a different name for the variable in either the first or second for loop.


Code:

gps = game:GetService("GamePassService");
id = 166087748 
VIP = {"Player1"} 
players = game.Players:GetPlayers()

for v=1,#VIP do --Number for vip is stored in a variable called v instead of i.
	for i=1,#players do --i is kept as the variable here.
		if players[i].Name:lower() == VIP[v]:lower() or gps:PlayerHasPass(players[i], id) then --Using string.lower so that if you capitalize someone's name wrongly, it won't matter.
			players[i].PlayerGui.Gui.TextButton.Visible = true
		else return end
	end
end

I hope my answer helped you. If it did, be sure to accept

3 comments

0

Still did not work

0

Get rid of .Name after VIP[v] as "Player1" is already a string. I will edit the script also to reflect some new changes.

0

Edited script, should work.

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