How do I make a spawn where only a certain team can spawn?

I am trying to make a script where if I am in a certain groups it teams me to a certain team and spawns me at another spawn. So far the team script has worked, but I cannot spawn at the correct spawn.

This is the script I’ve tried so far.

:lua:

function onPlayerEntered(plyr)
if plyr:IsInGroup(9662905) then
plyr.TeamColor = BrickColor.new(“Electric blue”)
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

:lua:

Please help me. :slight_smile:

3 Likes

Are the spawns correctly set up for each team? If so, you can just do plyr:LoadCharacter() to respawn them to the spawn after setting their team

first of all. :lua: doesn’t work here. To format lua code, write three backticks (```) to open and close your code. Now, i’ll fix your script.

game:GetService("Players").PlayerAdded:Connect(function(plyr) 
     plyr.CharacterAdded:Connect(function()
            if plyr:IsInGroup(9662905) then
                   if not plyr.TeamColor == BrickColor.new(“Electric blue”) then
                              plyr.TeamColor = BrickColor.new(“Electric blue”)
                              plyr.Character:BreakJoints() -- kills them to make them spawn again
                  end
            end
     end)
end) 

Doesn’t work, do I tried putting it in ServerScriptService and it still didn’t work. Could you give me a close up on how to do it?

I can’t debug this script right now. I’ll get back to you

1 Like

Did you correctly set up the spawn locations? If so, it’s likely it’s not working because you’re changing the TeamColor of the player rather than setting the team of the player to a specific team

You don’t need scripts for this. Let me explain.

To make a team only spawn, first, place a spawn. Then, under the “Teams” category, uncheck “Nuetral”. Change the TeamColor of the spawn to the Team’s color (make sure it lines up directly!).

Next, go into your Team. Make sure its TeamColor is the same as the spawn. Uncheck AutoAssignable, and BOOM! you have a spawn that only your team can spawn at :slight_smile:

Edit: To first spawn them there, once you assign their team, just reset their character or do

Humanoid:LoadCharacter()

If this is the answer, please mark it, so people know it was solved :wink:

1 Like

doesn’t the basic spawner on roblox have a team spawn property?

1 Like

I’d like it to respawn them, as killing them ruins the kill leaderboard

Humanoid:LoadCharacter()