My script is:
-- Establish the blank variables.
local map
local distanceToBuilding
local buildingPart
local morph
print("Standby")
wait(0.5)
game.Players.PlayerAdded:Connect(function(player)
wait(0.5)
local debris = player:WaitForChild("leaderstats").Debris
local character = player.Character
print("standby")
print("Map Detected!")
map = workspace:WaitForChild("Map", 100)
while game.ReplicatedStorage.Status.Value == "Game in progress." do
for i, building in pairs(map:FindFirstChild("Buildings"):GetChildren()) do
buildingPart = building:FindFirstChild("ColorParts").Floor1 or building:FindFirstChild("Leaf")
print(buildingPart)
distanceToBuilding = player:DistanceFromCharacter(buildingPart.Position)
print(distanceToBuilding)
morph = character:WaitForChild("Morph")
if distanceToBuilding <= 10 then
building.Health.Value = building.Health.Value - morph.Damage.Value
debris.Value = debris.Value + math.random(10,20)
elseif distanceToBuilding >= 10 and distanceToBuilding <= 15 then
building.Health.Value = building.Health.Value - morph.Damage.Value * 0.5
debris.Value = debris.Value + math.random(5,10)
elseif distanceToBuilding >= 15 and distanceToBuilding <= 20 then
building.Health.Value = building.Health.Value - morph.Damage.Value * 0.1
debris.Value = debris.Value + math.random(5,10)
else
print("Building too far away.")
end
if building.Health.Value <= 0 then
building:Destroy()
end
end
wait(1)
end
end)
It will print Standby the first time, but then it won't do anything. Even when a map spawns, nothing happens. Help.

9 comments
you do way too many FindFirstChilds, if you know the hierarchy is going to be the same every time, then you should just use building.Health. Also you should know that there is a WaitForChild, so you can replace that repeat FindFirstChild loop.
So, do repeat wait(1) until workspace:WaitForChild("Map")
Also instead of doing a ton of unconnected if statements, try using if else's. The only actual problem I see though is you don't handle anything if the player's distance to building is over 20.
no, no repeat at all
just map = Workspace:WaitForChild("Map",10) the 10 is how many seconds until you skip on to the rest of the code.
Still doesn't work. I have posted new code in the question.
Are you sure that you tried everything? Your new code still does not handle anything for when distance > 20
Hold on, take a step back for a bit, and explain what you want your code to actually do because I think there's something that isn't behaving the way you want it to other than what this code says it is doing.
The else covers the distance greater than 20