I'm honestly clueless on what to do. Basically I have a gamepass and when the user purchases it they have something they can do. In the end, I want the script to run and when they join the game if the player has the gamepass I want it to turn a textbutton visibility to true (Does not matter what the name of the gui is). I checked the wiki but there example just seemed to confusing for me. Maybe if someone could explain it a little more and show me how to do it I might get a better understanding. Thanks!
local GamePassService = game:GetService("GamePassService") local GamePassId = 185260715 game.Players.PlayerAdded:connect(function(player) if GamePassService:PlayerHasPass(player, GamePassId) then print("Username: " ..player " got dat pass") game.Players[player].PlayerGui.MenuGUI.Menu.twoDoff.Visible = true end end)
Your error is line 7.
game.Players[player].PlayerGui.MenuGUI.Menu.twoDoff.Visible = true
The player
parameter is equal to the player object that joins the game. It is not a string. You could technically do,
game.Players[player.Name]
but this is completely unnecessary and pointless! player
is the player object, so you can use it directly!
player.PlayerGui.MenuGUI.Menu.twoDoff.Visible = true
In some situations, like when the player is lagging, you may want to delay the PlayerAdded event until their character is loaded, to prevent errors.
repeat wait() until player.Character
or, when using PlayerGui, delay the script until the PlayerGui is loaded.
player:WaitForChild("PlayerGui")