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
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)
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
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
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