Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a player spawn somewhere using script?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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!

Ad

Answer this question