I created this team script system to where folks in particular groups would spawn on particular teams. Also, we made it to where there was an initial spawn of the character, execution of the team placement, and then ANOTHER respawn to allow the character to get on the correct SpawnLocation.
This all worked until I had someone implement a jail script for me.
The jail script works but directly contradicts my previous script because it also includes scripts involving loading characters in. The jail script has multiple scripts so I'll do my best to organize them. It also contains a reference to two things located in ReplicatedStorage which is important to the script; here are those for context:
http://prntscr.com/idg2gm http://prntscr.com/idg2ok
Here is the team script I made:
local players = game:GetService("Players") players.PlayerAdded:Connect(function(player) -- team colors local ManageColor = "Magenta" local CIAColor = "Daisy orange" local FBIColor = "Really blue" local DOSColor = "Mauve" local DODColor = "Bright red" local DOJColor = "Grime" local CONGRESSColor = "Crimson" local CIVColor = "Deep orange" local POTUSColor = "Storm blue" local PRIColor = "Plum" local MEXICANColor = "New Yeller" local USCColor = "Terra Cotta" local SSColor = "Really black" local USCPColor = "Cyan" local VPOTUSColor = "Deep blue" local WHSColor = "Institutional white" -- group ids local USAID = 2533418 local WHSID = 2533427 local USCID = 2547905 local SSID = 2534270 local CPID = 2660170 local FBIID = 2679501 local CIAID = 2534313 local DODID = 1191022 or 2533979 local DOSID = 2533483 local DOJID = 2534038 local SENATEID = 2533428 local HOUSEID = 2533429 -- -- init -- teams if player:GetRoleInGroup(USAID) == "Founder" or player:GetRoleInGroup(USAID) == "Group Manager" then player.TeamColor = BrickColor.new(ManageColor) elseif player:GetRoleInGroup(USAID) == "President of the United States" then player.TeamColor = BrickColor.new(POTUSColor) elseif player:GetRoleInGroup(USAID) == "Vice President of the United States" then player.TeamColor = BrickColor.new(VPOTUSColor) elseif player:GetRoleInGroup(USAID) == "Foreign Dignitary" then player.TeamColor = BrickColor.new(DOSColor) elseif player:GetRoleInGroup(USAID) == "Federal Prison" then player.TeamColor = BrickColor.new(PRIColor) elseif player:GetRoleInGroup(USAID) == "Immigrant" or player:GetRoleInGroup(USAID) == "Immigrant [Failed]" then player.TeamColor = BrickColor.new(MEXICANColor) elseif player:IsInGroup(USCID) then player.TeamColor = BrickColor.new(USCColor) if player:GetRoleInGroup(USCID) == "Pending" then player.TeamColor = BrickColor.new(USCColor) end elseif player:IsInGroup(SENATEID) then player.TeamColor = BrickColor.new(CONGRESSColor) elseif player:IsInGroup(HOUSEID) then player.TeamColor = BrickColor.new(CONGRESSColor) elseif player:IsInGroup(SSID) then player.TeamColor = BrickColor.new(SSColor) if player:GetRoleInGroup(SSID) == "Suspended" then player.TeamColor = BrickColor.new(CIVColor) end elseif player:IsInGroup(CPID) then player.TeamColor = BrickColor.new(USCPColor) if player:GetRoleInGroup(CPID) == "Suspended" then player.TeamColor = BrickColor.new(CIVColor) end elseif player:IsInGroup(FBIID) then player.TeamColor = BrickColor.new(FBIColor) if player:GetRoleInGroup(FBIID) == "Pending" or player:GetRoleInGroup(FBIID) == "Suspended" then player.TeamColor = BrickColor.new(CIVColor) end elseif player:IsInGroup(CIAID) then player.TeamColor = BrickColor.new(CIAColor) elseif player:IsInGroup(WHSID) then player.TeamColor = BrickColor.new(WHSColor) elseif player:IsInGroup(DOSID) then player.TeamColor = BrickColor.new(DOSColor) elseif player:IsInGroup(DOJID) then player.TeamColor = BrickColor.new(DOJColor) elseif player:IsInGroup(DODID) then player.TeamColor = BrickColor.new(DODColor) local ARMYID = 1191022 local DODID = 2533979 if player:GetRoleInGroup(ARMYID) == "[Pending]" or "[BCT]" or player:GetRoleInGroup(DODID) == "Suspended" then player.TeamColor = BrickColor.new(CIVColor) end elseif player:IsInGroup(USAID) then player.TeamColor = BrickColor.new(CIVColor) -- follow through end end)
This is the script that gives handcuffs to certain people in certain SpawnLocations
local plrs = game:GetService("Players"); local colors = { ["Cyan"] = true; ["Really blue"] = true; ["Really black"] = true; } local plrs_that_can_be = { ["KingLoneCat"] = false; ["Player1"] = false; ["KingBoneCat"] = false; ["TerenceWalsh"] = false; ["Le_JuiceBOX"] = false; } local perm_prisoners = { 2533418 } function check_ids(plr) local rank = 120; for _, value in next, perm_prisoners do if plr:GetRankInGroup(value) == rank then return true; end end return false; end plrs.PlayerAdded:Connect(function(plr) if plrs_that_can_be[plr.Name] then plr.TeamColor = BrickColor.new("Cyan"); end if check_ids(plr) then plr.TeamColor = "Plum"; plr.Neutral = false; end plr.CharacterAdded:Connect(function(char) for _, obj in next, char:GetChildren() do plr:LoadCharacterAppearance(obj); end local prisoner = plr:FindFirstChild("Prisoner"); if check_ids(plr) then plr.TeamColor = "Plum"; end if prisoner then local scr = script:WaitForChild("Timer"):Clone(); local owner = scr:WaitForChild("Owner"); local color = scr:WaitForChild("Color"); scr.Parent = char; owner.Value = plr; color.Value = prisoner:WaitForChild("Color").Value; scr.Disabled = false; end if colors[plr.TeamColor.Name] then print("Giving tool."); local tool = script:WaitForChild("Handcuffs"):Clone(); tool.Parent = plr:WaitForChild("Backpack"); end end) end)
This is the script that allows the particular tool to make the arrest.
local plrs = game:GetService("Players"); local rs = game:GetService("ReplicatedStorage"); local tool = script.Parent; local plr = plrs.LocalPlayer; local lc = rs:WaitForChild("LoadCharacter") tool.Activated:Connect(function() local mouse = plr:GetMouse(); local obj = mouse.Target; local char; if obj.Parent:IsA("Accessory") then char = obj.Parent.Parent; else char = obj.Parent; end local hum = char:FindFirstChild("Humanoid"); if hum then local victim = plrs:GetPlayerFromCharacter(char); print(victim.Name); local prison_team = BrickColor.new("Plum"); if victim.TeamColor == prison_team then local start_timer = rs:WaitForChild("Start_Timer"); start_timer:FireServer(victim) else local prisoner = Instance.new("StringValue"); prisoner.Parent = victim; prisoner.Name = "Prisoner"; local color = Instance.new("BrickColorValue"); color.Value = victim.TeamColor; color.Parent = prisoner; color.Name = "Color"; victim.TeamColor = prison_team; end victim.Neutral = false; lc:FireServer(victim); end end)
This is the script that sets a timer for folks in the jail.
local plr = script:WaitForChild("Owner").Value; local prev_color = script:WaitForChild("Color").Value; local time_needed = 300; local rs = game:GetService("ReplicatedStorage"); local event = rs:WaitForChild("Start_Timer"); function do_it() plr.TeamColor = prev_color; plr.Neutral = false; plr:FindFirstChild("Prisoner"):Destroy(); plr:LoadCharacter(); end function automatic() wait(time_needed) do_it(); end event.OnServerEvent:Connect(function(_, victim) if victim == plr then do_it(); end end) automatic();
This is the script that I believe refers to the ReplicatedStorage contents above
local rs = game:GetService("ReplicatedStorage"); local lc = rs:WaitForChild("LoadCharacter"); lc.OnServerEvent:Connect(function(_, plr) plr:LoadCharacter(); end)
If anyone would be interested in helping, I would be very appreciated. If this is too complex a thing to resolve over the forum, I'd be happy to add anyone on Discord to discuss further if necessary. Thanks!