Hello, I am attempting to make a Capture The Flag (CTF) game. My script works although, when I add a team check the scripts breaks but there is no error, no idea what the issue is.
Here is my code -
local Debounce = false
local IsCarryingFlagR = nil
game.Workspace.FlagStandR.Part1.Touched:Connect(function(Player)
local Character = Player.Parent
local PlrFilePlayer = game.Players:GetPlayerFromCharacter(Player.Parent)
if Character then
if IsCarryingFlagR == nil or IsCarryingFlagR == false then
if PlrFilePlayer.TeamColor == BrickColor.new("Cyan") then
if Debounce == false then
Debounce = true
local Humanoid = Character:FindFirstChild("Humanoid")
local FlagAccessory = game.ServerStorage.RedFlagAccessory:Clone()
FlagAccessory.Parent = Player.Parent
IsCarryingFlagR = true
game.Workspace.RedFlagPart:Destroy()
Humanoid.Died:Connect(function()
local NewRedFlagPart = game.ServerStorage.RedFlagPart:Clone()
NewRedFlagPart.Name = "RedFlagPart"
NewRedFlagPart.Parent = game.Workspace
IsCarryingFlagR = false
end)
wait(5)
Debounce = false
end
end
end
end
end)
This is where it breaks -
if PlrFilePlayer.TeamColor == BrickColor.new("Cyan") then

1 comment
also, tbh replicated storage is a better place to put stuffs to be cloned. Make a folder name Flags, and put the flags there.