Hello..
I'm trying to make a GUI that only appears when the player in the game has a specific GamePass I have created. I inserted the script into ServerScriptService, and have the GUI's visibility off before the player joins the game.
The code I got in the output was: Expected identifier when parsing expression, got 'then'
Does anybody have a solution for this?
I'm a beginner at scripting, so here is my code:
local id = 11949150 game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) if game:GetService("GamePassService"):PlayerHasPass(plr,id) then plr.PlayerGui.YeetGui.YeetLabel.Visible = true end end) end)
Hey there!
I have my own function I use for this that I will provide.
local MarketPlaceService = game:GetService("MarketplaceService") local function check(player,id) local s,res = pcall(MarketPlaceService.UserOwnsGamePassAsync,MarketPlaceService,player,id) if not s then res = false end return res end game.Players.PlayerAdded:Connect(function(player) plr.CharacterAdded:Connect(function(char) if check(player.UserId,11949150) then -- player userid, gamepass id player.PlayerGui.YeetGui.YeetLabel.Visible = true end end) end)
From the views of your script you rather used GamepassService then MarketPlaceService.
I believe this was the issue so if you don't want to use my whole script you can simply change some things that seem to not work like GamepassService to MarketPlaceService and PlayerHasPass to UserOwnsGamepass.
I just had this script written down so I hope it helps you out.