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)
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)