Gamepass Team Problem

I don’t know why this is happening.

(Basically, Team are spawning on the wrong “SpawnLocation”)

Script:

    local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer

local GamepassID = ******

script.Parent.MouseButton1Click:Connect(function()
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamepassID)
	then player.Team = game.Teams:WaitForChild("test") 
		player.Character.Humanoid.Health = 0
	end
end)

Did you set the TeamColor to it’s corresponding team color?

You know, for the SpawnLocation?

To add on to this reply, make sure the spawn is not Neutral so that only the team that is specified can spawn on the SpawnLocation

1 Like

You doing team change on client side. This should be executed by server. You may use for this RemoteEvent

Here’s my example:

Client script

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.TeamsRE:WaitForChild("test")
end)

Server script

local Remote = Instance.new("RemoteEvent",game.ReplicatedStorage)
Remote.Name = "TeamsRE"

local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 0

Remote.OnServerEvent:Connect(function(Player,Team)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then --// Checks if player have gamepass
		local team_ = game.Teams:FindFirstChild(Team) --// Find team
		if team_ then --// If team found
			Player.Team = team_ --// Sets team
			Player:LoadCharacter() --// Respawn character
		end
	end
end)
6 Likes