#I don't understand why my break isn't stopping the loop

1 messages · Page 1 of 1 (latest)

lofty ice
#

I thought that a break statement kicks in after a certain requirement is met, so that the same thing can't keep happening over and over again. However, mine isn't doing that, and I'm not sure why.

#
local function minCall(player, pos, size, calling, params)
    
    local brickmin = _G["Brickmin"]
    local brickminHRPs = _G["BrickminHRPs"]
    
    local parentModel;
    
    params.FilterDescendantsInstances = {brickminHRPs}
    params.FilterType = Enum.RaycastFilterType.Include

    local partsInCallDot = workspace:GetPartBoundsInRadius(pos, size.X * 0.5, params)
    
    if (#partsInCallDot) and calling then
        
        for i,v in pairs (partsInCallDot) do
            parentModel = v:FindFirstAncestorOfClass("Model")
                
            if parentModel then
                print(parentModel.Name .. " was called by " .. player.Name)
                addBrickminToSquad:Fire(parentModel.Name)
                break
            end
        end
    end    
end

getCallDotInfo_RE.OnServerEvent:Connect(function(player, pos, size, calling, color, trans)
    
    callDot.Size = Vector3.new(size.X, size.Y, size.Z)
    callDot.Position = pos
    callDot.BrickColor = color
    callDot.Transparency = trans
    callDot.Name = player.Name .. "s CallDot"
    
    if calling then 
        minCall(player, pos, size, calling, params)
    end
    
end)```
#

its the if parentModel then print(parentModel.Name .. " was called by " .. player.Name) addBrickminToSquad:Fire(parentModel.Name) break that is where the issue is at