Script for specific team keeps running even when team changed

greetings all, this is a script which i have which is a group rank team only spawn, it works perfectly fine when im on the “combine” team, though when i switch to a different team, the script still makes me respawn at the “combine” team spawn when i want it to spawn somewhere else, i believe the script just doesn’t register the player team has changed, but i’m not sure how to go about fixing this, i attempted using Player:GetPropertyChangedSignal(“Team”):Connect(function() but i’m not exactly sure how to use it in here since i’m not a scripter

local SpawnPart = workspace:WaitForChild("benefactorspawn")
local SpawnPart2 = workspace:WaitForChild("menuspawn")-- Set this to the part you want (Not a spawn part but a regular part)
local GroupID = 16221838 --Set this to your group id
game.Players.PlayerAdded:Connect(function(player)
	if player:GetRankInGroup(GroupID) == 255 and player.Team.Name == "Combine" then
		player.Character:MoveTo(SpawnPart.Position+Vector3.new(0,2.5,0))
		player.CharacterAdded:Connect(function(char)
			wait()
			char:MoveTo(SpawnPart.Position+Vector3.new(0,2.5,0))
		end)
	elseif player:GetRankInGroup(GroupID) == 255 and player.Team.Name == "Menu" then
		player.CharacterAdded:Connect(function(char)
		wait()
		char:MoveTo(SpawnPart2.Position+Vector3.new(0,2.5,0))
		end)
	end
end)
local spawns = {
    SpawnPart1 = workspace:WaitForChild("benefactorspawn");
    SpawnPart2 = workspace:WaitForChild("menuspawn");
}
local GroupID = 16221838

game.Players.PlayerAdded:Connect(function(player)
    if player:GetRankInGroup(GroupID) ~= 255 then return end
	player.CharacterAdded:Connect(function(char)
		char:PivotTo(spawns[string.format("SpawnPart%i", player.Team.Name == "Combine" and 1 or 2)]:GetPivot() * CFrame.new(0, 2.5, 0))
	end)
end)
1 Like

What should I do if I have 2 more teams with other spawns?

The other 2 teams are called, “Rebel” and “Citizens”

local extraSpawns = {
    Spawn1 = workspace:WaitForChild("rebelspawn");
    Spawn2 = workspace:WaitForChild("citizenspawn");
}

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:PivotTo(extraSpawns[string.format("Spawn%i", player.Team.Name == "Rebel" and 1 or 2)]:GetPivot() * CFrame.new(0, 2.5, 0))
    end)
end)

Doesn’t work unfortunately, it just spawns me at the “menuspawn” from the previous script.

Because you’re the owner of the group, taking priority.

So I just can’t play on other teams then?

The code you began with shows a group ranking system. So no.

Oh well, thanks for the help anyway. I’ll try find a solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.