i have a capture the flag script that increases the score when you are inside the area the problem is that it isnt going up
it prints “test2” but the score doesnt change
my script:
local RS = game:GetService("ReplicatedStorage")
local GS = RS.GermanyScore
local AS = RS.AmericaScore
local GermanyScore = 0
local AmericaScore = 0
local range = 50
local flag = script.Parent
local Teams = game:GetService("Teams")
local players = game:GetService("Players")
local Distance
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
task.wait()
local HRP = char:WaitForChild("HumanoidRootPart")
local Humanoid = char:WaitForChild("Humanoid")
Distance = (HRP.CFrame.p - flag.CFrame.p).Magnitude
while true do
if Distance < range and Humanoid.Health > 0 and plr.TeamColor == BrickColor.new("White") then
repeat
GermanyScore = GermanyScore + 1
print("test")
wait(1)
until
Distance > range or Humanoid.Health == 0
elseif Distance < range and Humanoid.Health > 0 and plr.TeamColor == BrickColor.new("Bright red") then
repeat
AmericaScore = AmericaScore + 1
print("test2")
wait(1)
until
Distance > range or Humanoid.Health == 0
end
print("Germany".."["..GermanyScore.."]".."-".."America".."["..AmericaScore.."]")
AS.Value = AmericaScore
GS.Value = GermanyScore
task.wait(0.1)
end
end)
end)