Hello! I’m having this issue where this function was returning correct values before but now it is only returning nil
Everything needed is properly referenced and in the right area (trust me I quadruple checked)
Below is the problematic function
local function AddPlaceholderTower(name)
print("Tower", name, "has been requested")
local towerExists = Towers:FindFirstChild(name)
print(towerExists) -- Line 42
if towerExists then
print("Tower", name, "does exist and has been spawned")
towerToSpawn = towerExists:Clone()
towerToSpawn.Parent = workspace
for i,object in ipairs(towerToSpawn:GetDescendants()) do
if object:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(object, "Tower")
object.Material = Enum.Material.ForceField
end
end
end
end
Below is the function calling the function
for i, tower in pairs(Towers:GetChildren()) do
local button = GUI.TowerList.Template:Clone()
button.Name = tower.Name
button.Parent = GUI.TowerList
print(tower.Name)
button.Activated:Connect(function()
AddPlaceholderTower(tower)
print(button.Name.." clicked") -- Line 74
end)
end
Below is the output:
09:44:04.599 Scout - Client - GameController:70
09:44:04.599 Spinbot - Client - GameController:70
09:44:06.963 Tower Scout has been requested - Client - GameController:40
09:44:06.965 nil - Client - GameController:42
09:44:06.965 Scout clicked - Client - GameController:74