Defining team spawn and changing teams on touch

I need to make two blocks that when touched, will kill the player, set their team, and spawn them in a different location.

local teamChangeRed = script.Parent.Red
local taemChangeBlue = script.Parent.Blue
local debounce = true
local redTeam = {}
local blueTeam = {}

function TeamSetting(tableName1,tableName2,playerName)
	if not table.find(tableName1,playerName) then
		table.insert(tableName1,playerName)
	end
	if table.find(tableName2,playerName) then
		table.remove(tableName2,table.find(tableName2,playerName))
	end
end

function RedTeam(Hit)
	local humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
		if debounce then
			debounce = false
			TeamSetting(redTeam,blueTeam,player.Name)
			print("You Have Joined Red Team")
			player.RespawnLocation = script.Parent.SpawnLocation1
			humanoid:TakeDamage(100)
			wait(1)
			debounce = true
		end
	end
end

function BlueTeam(Hit)
	local humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
		if debounce then
			debounce = false
			TeamSetting(blueTeam,redTeam,player.Name)
			print("You Have Joined Blue Team")
			player.RespawnLocation = script.Parent.SpawnLocation2
			humanoid:TakeDamage(100)
			wait(1)
			debounce = true
		end
	end
end

teamChangeRed.Touched:Connect(RedTeam)
taemChangeBlue.Touched:Connect(BlueTeam)

hi i did it as you want it
there is a picture of objects to
na
name objects like in the picture
or there is a link for try in studio
https://www.roblox.com/library/9107851255/TeamSystem
i hope it helps

i have put the players to arrays for teams that way you can create gui or team system to colourise them as you wish

https://developer.roblox.com/en-us/api-reference/property/SpawnLocation/AllowTeamChangeOnTouch