Hi guys, I am trying to make a Terminal script For that, I have 3 flags, and then a primary terminal the team2 should capture all the 3 flags so they can get the terminal. while the team1 should stop team2.
so far, I have tried making this script.
local Terminal = game.Workspace:FindFirstChild("Terminal")
local Generator1 = game.Workspace:FindFirstChild("Generator1")
local Generator2 = game.Workspace:FindFirstChild("Generator2")
local Generator3 = game.Workspace:FindFirstChild("Generator3")
local Gen1 = false -- False means it belongs to NRC, True means it belongs to Raiders
local Gen2 = false -- "
local Gen3 = false -- "
local Term = false -- "
local Team1 = BrickColor.new("Electric blue")
local Team2 = BrickColor.new("Persimmon")
local Capturing = false
function CaptureGenerator(Generator, Hit, Captured)
if Capturing == false then
Capturing = true
if Hit and Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("Humanoid").Health > 0 then
local Character = Hit.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
if Character and Player then
local Player_TeamColor = Player.TeamColor
if Captured == false and Player_TeamColor == Team2 then
Captured = true
Generator.BrickColor = Player_TeamColor
elseif Captured == true and Player_TeamColor == Team1 then
Captured = false
Generator.BrickColor = Player_TeamColor
elseif Captured == false and Player_TeamColor == Team1 then
print("You already own this generator!")
elseif Captured == true and Player_TeamColor == Team2 then
print("You already own this generator!")
end
end
end
Capturing = false
end
end
Generator1.Touched:connect(function(Hit)
CaptureGenerator(Generator1, Hit, Gen1)
end)
Generator2.Touched:connect(function(Hit)
CaptureGenerator(Generator2, Hit, Gen2)
end)
Generator3.Touched:connect(function(Hit)
CaptureGenerator(Generator3, Hit, Gen3)
end)
If you guys can notice, Everything seems fine here, But here's the deal. When I try to capture a flag with team1 and then try again, it should be printing that "I already own this generator" but, this is not happening. When I try to change my team to team2 and then try to capture it, it says "You already captured this"
It's going wrong way around! Please help me
// udayk8139
