Help With Custom Spawn Thing

So im trying to make a thing where when someone on the other team gets to close to the other spawn the teams switch sides.

the problem im having is for some reason its not printing “Switch Sides” and I cant figure out why

local CurrentLocation = script.Parent
local Debounce = false
local Teams = game:GetService("Teams")

local Alpha = Teams:WaitForChild("Alpha")
local Bravo = Teams:WaitForChild("Bravo")

CurrentLocation.Touched:Connect(function(Touch)
	if Touch.Parent:FindFirstChild("HumanoidRootPart") and Debounce == false then

		Debounce = true
		local player = game.Players:GetPlayerFromCharacter(Touch.Parent)
		if player and player.Team.Name ~= script.Parent["Current Team"].Value then
			print("On Other Team")
			
			if player:WaitForChild(Teams) == Alpha then
				print("Switch Sides")
			end
			
		end
		Debounce = false
	end

end)
1 Like

What about player:WaitForChild(Teams).Team == Alpha?

I think so but im not using roblox’s spawn points

Ohhhhhh That makes more sense.

This line is the issue; You’re trying to access the teams service through the player?
Replace it with player.Team.

local CurrentLocation = script.Parent
local Debounce = false
local Teams = game:GetService("Teams")

local Alpha = Teams:WaitForChild("Alpha")
local Bravo = Teams:WaitForChild("Bravo")

CurrentLocation.Touched:Connect(function(Touch)
	if Touch.Parent:FindFirstChild("HumanoidRootPart") and Debounce == false then

		Debounce = true
		local player = game.Players:GetPlayerFromCharacter(Touch.Parent)
		if player and player.Team.Name ~= script.Parent["Current Team"].Value then
			print("On Other Team")
			
			if player.Team == Alpha then
				print("Switch Sides")
			end
			
		end
		Debounce = false
	end

end)

I did have it that way for a while but that wasn’t working either

Try replacing it with Player.Team.Name == " Alpha" maybe it will work

1 Like

tried that too and it didn’t work.

name of team is not same as name of service.
you must change line
if player:WaitForChild(Teams) == Alpha then

to
if player.Team.Name == “Alpha” then