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

How do I set someone onto a team when the join if they own my gamepass?

I want to make a script in which when a player joins my game, they'll immediately be put onto a team no one else can join unless they also own the gamepass. This is a script I tried when combining the gamepass detection and team color codes but it hasn't worked. Any ideas? Many thanks!

1|local passId = 512383233 -- change this to your game pass ID. 2| 3|function isAuthenticated(player) -- checks to see if the player owns your pass 4| return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId) 5|end 6| 7|game.Players.PlayerAdded:connect(function(plr) 8| if isAuthenticated(plr) then 9| game.Players["player"].TeamColor = BrickColor.new("Eggplant") 10| end

2 comments

0
  1. Do you know how to check if someone has your gamepass? 2) Do you know how to set someone to a team? 3) Do you know how to use a code block?
0

Not really advanced but kinda.

1 answer

✓ Accepted answer

Try this.

game.Players.PlayerAdded:connect(function(plr)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, 512383233) then
        game.Players[plr.Name].TeamColor = BrickColor.new("Eggplant")
        print("Player owns the gamepass!")
    else
        print("Player does not own the gamepass!")
    end
end)

Put it in a regular script, and that in Workspace.

1 comment

0

Works perfectly, thank you very much!

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