Im making a script that if a player haves the gamepass. It should move the player to | Vip Team
Should this script work or not? I can’t test it thats why im asking
Im making a script that if a player haves the gamepass. It should move the player to | Vip Team
Should this script work or not? I can’t test it thats why im asking
Your not supposed to have a ‘.’ at line 7. Try removing that. (Between ‘Teams’ and [“| Vip”])
Edit: Also, try using MarketPlaceService to check if the player has the gamepass.
ok thanks man but if i delete that should it work?
GamePassService is deprecated. Since you have something, I can help you now.
local MPS = game:GetService("MarketplaceService")
local gamepass = script:FindFirstChild("GamePassId")
local teams = game:GetService("Teams")
game.Players.PlayerAdded:Connect(function()
if MPS:UserOwnsGamePassAsync(player.UserId,gamepass.Value) then
player.Team = Teams["TEAMNAME"]
end
end)
The script you had wouldve worked about 2 years ago. And while technically it will still work its very complicated to get it to work, you should be using MarkeplaceService
local Players = game:GetService('Players')
local MarketplaceService = game:GetService('MarketplaceService')
local Teams = game:GetService('Teams')
local Team = Teams['TeamName']
local GamePassId = script.GamePassId -- GamePassId will already exist on the server, no need for WaitForChild here.
local function PlayerAdded(Player)
local OwnsGamePass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassId.Value)
if OwnsGamePass then
Player.Team = Team
end
end
-- Loop through existing players.
local GetPlayers = Players:GetPlayers()
for i = 1, #GetPlayers do
coroutine.resume(coroutine.create(function()
-- Runs this function in parallel for each player.
PlayerAdded(GetPlayers[i])
end))
end
Players.PlayerAdded:Connect(PlayerAdded) -- Listen for new players.