Hello there,
ModelisiYT, our scripter, actually works on a point capture system that could detect the amount of players, and the current team of the player. He actually made the script so the character could capture the flag after a certain time. However, as he may be absent for next two weeks, I want to help him finishing this up. The fact is that I don’t know where to put the if condition in the code so if a “teamcolor” hits, it activates then do all operations I want (maybe Cframe later, change the flag, the text color of the point… I don’t know, I will see later).
Here is the code ;
local FlagCounterF = workspace.Point.Model.GUI.BillboardGui.Frame.Frame2
local Plate = script.Parent
local FlagValue = 60
local PlayerCount = 0
local ResetCounter = 5
Plate.Touched:Connect(function(Hit)
local hitChildren = Hit.Parent:GetChildren()
for i = 1, #hitChildren do
print(hitChildren[i])
if hitChildren[i].Name == "Humanoid" then
PlayerCount = PlayerCount + 0.5
end
end
ResetCounter = 5
print(PlayerCount)
end)
Plate.TouchEnded:Connect(function(Hit)
local hitChildren = Hit.Parent:GetChildren()
for i = 1, #hitChildren do
print(hitChildren[i])
if hitChildren[i].Name == "Humanoid" then
PlayerCount = PlayerCount - 0.5
end
end
print(PlayerCount)
end)
while true == true do
wait(1)
print(PlayerCount)
print(FlagValue)
if FlagValue >= 0 then
FlagValue = FlagValue - PlayerCount
if FlagValue < 0 then
FlagValue = 0
end
else
FlagValue = 0
end
if PlayerCount == 0 then
if ResetCounter >= 1 then
ResetCounter = ResetCounter - 1
else
if FlagValue <= 55 then
FlagValue = FlagValue + 5
elseif FlagValue >= 56 then
FlagValue = 60
end
end
end
print(FlagValue)
FlagCounterF.Text = math.floor(FlagValue)
end
and the folder configuration of the flag.
I thought about putting the following ;
if player and player.TeamColor == BrickColor.new("Bright red") then
end
I’m not sure if this will work actually. I’m a novice into LUA, so if you could be also very clear in what you say, it could be better for me. Thanks for future answers, I would be happy if you could help me.