So I have a script that controls the player's team on join based on their rank in a group. The team script works fine, yet I find myself spawning at the wrong Spawn Location every time.

Here's the script:

local RetronixID = 5509338
local DepartmentID = 5748319
local SecurityID = 5701845

function addToTeam(plr,TeamName)
	plr.TeamColor = game.Teams[TeamName].TeamColor
	plr:LoadCharacter()
end

function onPlayerAdded(plr)
	if plr:GetRankInGroup(RetronixID) >= 247 then
		addToTeam(plr,"Administration")
		giveTools(plr,"Admin")
		return
	end
	
	if plr:GetRankInGroup(SecurityID) > 0 then
		addToTeam(plr,"Security")
		giveTools(plr,"Security")
		return
	end
	
	if plr:GetRankInGroup(DepartmentID) > 0 then
		addToTeam(plr,"Department Member")
		giveTools(plr,"DepMember")
		return
	end
	
	if plr:GetRankInGroup(RetronixID) > 0 then
		addToTeam(plr,"Employee")
		giveTools(plr,"Employee")
		return
	end
end

function giveTools(plr,level)
	if level == "Employee" then
		--//Make employee keycard
	elseif level == "DepMember" then
		--//Give employee keycard and speed coil
	elseif level == "Security" then
		--//Make security keycard
	elseif level == "Admin" then
		local Keycard = game.ServerStorage.Tools.AdminKeycard:Clone()
		if plr.UserId == 422045341 or plr.UserId == 62097945 then
			local RoseJuice = game.ServerStorage.Tools.RoseJuice:Clone()
			RoseJuice.Parent = plr.Backpack
		end
		Keycard.Parent = plr.Backpack
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	onPlayerAdded(plr)
end)

For example, Administration team has the Dark stone grey BrickColor and is AutoAssignable off. The admin spawn has AllowTeamChangeOnTouch off, Neutral Off, and TeamColor set to Dark stone grey. I've read many articles and they all say that you should be sent to the spawn location based on the team color, but that is not happening. Is that an issue with my script, my configuration of the spawn point, or a roblox thing?

1 comment

0

This isn't really a scripting related question.