So I’m having some issues with my character not being loaded into the correct spawn area.
Video linked below.
So the spawn areas are loaded by what group you are in so for example if you are in the “Sparta Group” you will spawn at “Sparta Spawn”
And if you are not in any group affiliated with the game you will spawn at “Outsider Spawn” And be put on the “Outsider team”
I’m being loaded onto the correct team but for some reason I’m not being sent to the correct spawn the majority of the time.
I have found something sort of related I think? Basically if the name tag doesn’t load properly with the user they don’t go to the correct spawn but if it does then they do. (hope that makes sense but you can see what I mean in the video)
local Players = game:GetService("Players")
function setTeam(player, teamName)
player.TeamColor = game:WaitForChild("Teams")[teamName].TeamColor
player.Neutral = false
end
function toSpawn(player)
local s = game.Workspace.Spawns:WaitForChild(tostring(player.Team)):GetChildren()
local rand = Random.new()
local r = rand:NextInteger(1,#s)
player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(s[r].Position)
end
Players.PlayerAdded:Connect(function(player)
setTeam(player, "Menu")
player.CharacterAdded:Connect(function(chr)
if player:IsInGroup(6318983) then
setTeam(player, "Sparta")
else
if player:IsInGroup(17180419) then -- random group for testing kinda not needed rn change later
setTeam(player, "Rome")
else
setTeam(player, "Outsiders")
end
end
toSpawn(player)
end)
end)
– Name tag (not sure if this is associated with the problem
game.Workspace.ChildAdded:connect(function(plr)
local name = plr.Name
local player = game.Players:FindFirstChild(plr.Name)
if player ~= nil then
player.CanLoadCharacterAppearance = true
plr.Humanoid.DisplayDistanceType = "None"
if player:IsInGroup(6318983) then
local tag = game.ReplicatedStorage:WaitForChild("NameTag"):Clone()
tag.Group.Text = "-SPARTA-"
tag.Group.TextColor3 = Color3.fromRGB(196, 40, 28)
local tagset = false
-- BASE ROME
if not tagset then
local role = player:GetRoleInGroup(6318983)
tag.Parent = plr:WaitForChild("Head")
tag.Text.Text = name .. " | " .. role
end
else
local tag = game.ReplicatedStorage:WaitForChild("NameTag"):Clone()
tag.Group.Text = ""
tag.Parent = plr:WaitForChild("Head")
tag.Text.Text = name .. " | VISITOR"
end
end
end)
From my memory I believe these are the only 2 scripts that “mess” with the spawning and where everyone goes if I find something different I’ll be sure to update.
The actual spawns are just in the workspace like this, and no it doesn’t go off team color I believe
(altho I may be stupid but having trying that it doesn’t seem to work)
Not 100% sure on the specifics as this was done by an old collaborator (which I have no way of talking to now sadly) but I think it picked a random spawn out of the amount of spawns that were in the folder and just picked a random one for the player to spawn at.