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

Having issues with giving a screen gui when player buys a gamepass?

Here is the script:

local id = 749645444
game.Players.PlayerAdded:connect(function(player)
    if local HasPass = Game:GetService("GamePassService"):PlayerHasPass(player, id) then
player:findFirstChild("PlayerGui").Teleport.Visible = true else player:findFirstChild("PlayerGui").Teleport.Visible = false
local x = Instance.new("Message",Workspace)
x.Text = player.Name .. (HasPass and " has" or " doesn't have").. " the game pass!"
wait(2)
x:Remove()
end
end)

How do I make this script indicate that a GUI will be given to the players if they bought a gamepass?

2 comments

0

There's multiple problems, but I'll only point out where they're: Lines 3, 4, 6, 8.

0

u disliked I know u did @TheeDeathCaster

1 answer

✓ Accepted answer

I have left some comments below.

local GamePassService = game:GetService("GamePassService")
local id = 749645444

game.Players.PlayerAdded:Connect(function(Player)
    if GamePassService:PlayerHasPass(Player, id) then
        Player:FindFirstChild("PlayerGui").Teleport.Visible = true -- "findFirstChild" should be with a capital "F"
    else 
      	Player:FindFirstChild("PlayerGui").Teleport.Visible = false
        local x = Instance.new("Message",workspace)
        x.Text = Player.Name.. " does not have the game pass!" -- we don't need the "or" and "and" because, of course the player won't have it since it is in this else.
        wait(2)
        x:Destroy() --Destroying is better than removing
    end
end)

If this helped, please be sure to accept my answer if this helped :)

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