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

Expected identifier when parsing expression, got 'then' ??

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)

1 answer

✓ Accepted answer

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.

4 comments

0

Sorry but, I was getting an Error Message saying "UserOwnsGamepass is not a valid member of MarketplaceService". I was searching up all members of MarketPlaceService, but could'nt find anything that matches. I've got my script in ServerScriptService.

0

That's weird, try using my function I made and see if it works out for you.

0

Oh wow it worked when I used the whole script! The problem was that on line 12, "plr" is supposed to be "player" instead. Thanks!

0

Oh awesome!

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