Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a player spawn somewhere using script?

I want to make it so that when somebody joins the game, they spawn at a spawnlocation, but the spawnlocation is not neutral. So can I use script to make someone spawn at a spawnlocation that isn't neutral?

1 answer

Hello!

Firstly, make as many teams as you want. All teams must have a unique color and name, and set "AutoAssignable" to false.

Next, make at least 1 spawnlocation per team and make sure all spawnlocations have "Neutral" set to false and "AllowTeamChangeOnTouch" set to false. Assign the spawns to the teams you want by changing it's "TeamColor" to the same color of that team.

Lastly, paste this code into a normal script in ServerScriptService and do the necessary changes:

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

local Team1 = Teams.Team1  -- Change "Team1" to the name of your first team.
local Team2 = Teams.Team2  -- Change "Team2" to the name of your second team.
local Team3 = Teams.Team3  -- Change "Team3" to the name of your third team.
 
Players.PlayerAdded:Connect(function(player)
	player.Team = Team1  -- Change "Team1" to the name of the team players will spawn as.
	player:LoadCharacter()
end)

2nd Way Without Script: Choose the team you want players to spawn as and set "AutoAssignable" to true.

Hopefully I helped you!

This discussion is preserved as it was. New answers, comments, and votes are closed.