Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

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

Asked by 3 years ago

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

Log in to vote
3
Answered by
8oe 115 Donator
3 years ago
Edited 3 years ago

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.

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. stonyxvirgo 27 — 3y
0
That's weird, try using my function I made and see if it works out for you. 8oe 115 — 3y
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! stonyxvirgo 27 — 3y
0
Oh awesome! 8oe 115 — 3y
Ad

Answer this question